Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8645157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:28:38+00:00 2026-06-12T12:28:38+00:00

I created a .vbs file to create a folder in Outlook. I copied most

  • 0

I created a .vbs file to create a folder in Outlook.

I copied most of the script out of MSDN and get

“Expected End of Statement” error code 800A0401

Option Explicit
Dim myNameSpace As Outlook.NameSpace
Dim myFolder As Outlook.Folder
Dim myNewFolder As Outlook.Folder

Set myNameSpace = Application.GetNamespace("MAPI")
Set myFolder = myNameSpace.GetDefaultFolder(olFolderInbox)
Set myNewFolder = myFolder.Folders.Add("Postini")

Wscript.Echo "Folder created"
Wscript.Quit

Never created a .vbs script before.

Windows 7 64-bit and Outlook 2010. Running as local administrator.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:28:39+00:00Added an answer on June 12, 2026 at 12:28 pm

    This error is because you cannot dim variables as something in particular in VBS. Said more explicitly the “Dim” statement is used without defining the variable type in VBScript because all variables in VBScript are automatically of type Variant. If you attempt to Dim a variable as anything, it will throw an error.

    Instead, you want:

    Dim myNameSpace
    Dim myFolder
    Dim myNewFolder
    

    Additionally, you seem to have just copied some VBA from Outlook and tried to run it as VBS.

    VBscript does not know how to interpret Application.GetNameSpace("MAPI").

    You will need to also create an Outlook Application.

    dim myOutlook
    set myOUtlook = CreateObject("Outlook.Application")
    

    Also, since you cannot provide references in VBS, you have to use late binding for any objects (which is why I used CreateObject.) So re-written your code is as follows:

    Option Explicit
    Dim myOutlook
    Dim myNameSpace
    Dim myFolder
    Dim myNewFolder
    
    set myOUtlook = CreateObject("Outlook.Application")
    Set myNameSpace = myOutlook.GetNamespace("MAPI")
    Set myFolder = myNameSpace.GetDefaultFolder(6) '6 is the value of olFolderInbox
    Set myNewFolder = myFolder.Folders.Add("Postini")  
    Wscript.Echo "Folder created"
    Wscript.Quit
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to create a text file named listfile.txt in the folder C:\Documents and
Created an extensive batch script program to handle some automated file management and printing
I m in a very weird situation. I created a vbs script that would
I have a VBS list script to list file,with various dates. All of the
I need to create a .VBS script to reset the Windows local administrator password
I am trying to write a simple VBS script that will create folders on
I have created a VBS script in Windows. I will run this script to
I'm creating a VBS to create a user from our HR-systems. Most of it
I have this batch file: @echo off echo StrText=Application created Successfully > spk.vbs echo
I work with windows XP operation system When I create new vbs file on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.