Solved

VBA ERROR 400

Posted on 2009-06-30
6
1,646 Views
Last Modified: 2012-05-07
Hi, I created a macro to open all excel spreadsheets in a particular folder. However when I run the code, I get an error "Visual Basic 400"
Please can you tell me why?

Sub smiley_face()
'macro to open all files within a folder and apply password
 
strPassword = InputBox("Please enter your password")
 
sPath = "S:\Circulation\R Winters\"
 
sDir = Dir$(sPath & "*.xls", vbNormal)
 
Do Until LenB(sDir) = 0
Application.AskToUpdateLinks = False
Workbooks.Open Filename:=sPath & sDir, Password:=strPassword
sDir = Dir$
 
Loop
End Sub

Open in new window

0
Comment
Question by:tajinderpal
6 Comments
 

Expert Comment

by:r_johnston
ID: 24744037
0
 

Author Comment

by:tajinderpal
ID: 24744099
Sorry that did not help
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 24745015
Which line actually causes the error?
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:tajinderpal
ID: 24761880
It does not tell me what line the error is as. Just a pop up box appears with the error code 400
0
 
LVL 23

Expert Comment

by:Kamaraj Subramanian
ID: 24761899
Excel Error 400 is a "catch-all" error for something that Excel cannot resolve in de-coding Macro lines. It is applied to Application Define Errors or Object Define Errors.

Like you have a Variable defined as a type of number, but the data you are loading into it is a string or object. Bang-Error: 400.
0
 
LVL 23

Accepted Solution

by:
Kamaraj Subramanian earned 250 total points
ID: 24761918
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Batch Numbering 6 30
Excel Calculation 4 48
Response times in Excel 18 43
Stop display of alerts in Word via Excel 12 18
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question