Problem running macros in Excel filenames containing specialcharacters like []
I tried it and it didn't work for me:
Dim myName as string
'....
myName = Replace(Replace(ThisWorkbook.Name, "(", "["), ")", "]")
For i = LBound(mac_names) To UBound(mac_names)
With .Controls.Add(Type:=msoControlButton)
.OnAction = myName & "!" & mac_names(i)
It still tried to open a different file. And when it did, it looked like there
were two files open with the same name--and xl2003 sometimes crashed (and
sometimes not) when I tried closing one of them.
mike wrote:
After reading Dave's response, I see the problem differently. If the
present concern is the brackets in the filename, why not store
"ThisWorkbook.Name" to a string variable and then use string functions
to replace brackets with parenthesis? My snippet becomes
CommandBars("toolbar_name").Co*ntrols("Btn_Name"). OnAction = _
strWorkbookName & "!macro_name"
I haven't tried this but I see no reason why it shouldn't work.
--
Dave Peterson
|