Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA ERROR 400

Posted on 2009-06-30
6
Medium Priority
?
1,874 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 1000 total points
ID: 24761918
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
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.

610 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