Forum

File Name conventio...
 
Notifications
Clear all

File Name conventions in VBA

2 Posts
2 Users
0 Reactions
113 Views
(@mreevies)
Posts: 6
Active Member
Topic starter
 
Hi, I have created a macro that steps through folders and opens each individual workbook runs a standard macro in that workbook closes the file and moves onto the next file until all have been done.
I have used Application.Run (File.Name & "!UpdatePeriod") to call and run the macro, where UpdatePeriod is the macro name in each workbook. The issue I have is that if the filename may contain spaces or characters like (&-) and then the macro stops saying that it cannot access the macro. At the end of the macro I am resaving the file with a different name including the current period. Are there any guidelines or rules that I should be following in terms of naming conventions so that opening the file and running the macro is not an issue?

Many thanks in advance.

 
Posted : 11/06/2018 6:37 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi,

If you have posted this qs on another forum please let us know so we aren't duplicating effort.

As the answer on the other forum said, wrap your call in quotes

Application.Run ("'" & File.Name & "'!UpdatePeriod"

Or don't use spaces in filenames.  As a programmer I hate having to deal with spaces in filenames, URL's etc.

Phil
 
Posted : 11/06/2018 7:04 pm
Share: