Solved

VBA ERROR 400

Posted on 2009-06-30
6
1,598 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
Comment Utility
0
 

Author Comment

by:tajinderpal
Comment Utility
Sorry that did not help
0
 
LVL 85

Expert Comment

by:Rory Archibald
Comment Utility
Which line actually causes the error?
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

Author Comment

by:tajinderpal
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now