PDA

View Full Version : Problem With Macro



Floni
01-17-2018, 12:34 PM
Hi,

below my Macro:


Sub AllFiles()
Dim folderPath As String
Dim filename As String
Dim wb As Workbook

folderPath = "C:\Users\Dom\Desktop\Bob"

If Right(folderPath, 1) <> "\" Then folderPath = folderPath + "\"

filename = Dir(folderPath & "*.csv")
Do While filename <> ""
Application.ScreenUpdating = False
Set wb = Workbooks.Open(folderPath, Local:=True & filename)



Call ChangeFile


filename = Dir
Loop
Application.ScreenUpdating = True
End Sub

I need to open CSV file with data like Excel, so I wrote Local:=True, but then i have error:"run time error 1004 method open of object workbooks failed"

Any help is greatly appreciated!!

Dave
01-17-2018, 03:25 PM
If Right(folderPath, 1) <> "\" Then folderPath = folderPath & "\"
Note the "&" HTH. Dave
edit: Welcome to this forum!

Paul_Hossler
01-17-2018, 05:41 PM
Yes, welcome to the forum

I added CODE tags around your macro for formatting, but the next time you can use the [#] icon to insert the CODE and /CODE tags and paste your macro(s) between them

Floni
01-18-2018, 01:29 PM
Thank you I found solution.