Solved

VBA ERROR 400

Posted on 2009-06-30
6
1,712 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

717 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