Calling workbooks with apostrophes in name?
"Don Wiss" wrote...
In some of my spreadsheets I have one workbook run a macro in another open
workbook. The name of the workbooks are generally created by a macro, and
any apostrophes are removed. But sometimes the user puts them back in. And
it would be nicer to not remove them in the first place. An example line of
code that I'm using is:
Application.Run ("'" & TargetName & "'!HidePolicyPeriods")
How could it be written so apostrophes could be in TargetName?
When in doubt, experiment. Create a dummy file with an embedded single quote
in the filename. Then open another file and write a formula that refers to a
cell in the first workbook. Once you've entered the formula, how does the
filename appear? On my system, the single quotes are doubled, so an external
reference to Sheet1!A1 in a file named foo'bar.xls appears as
='[foo''bar.xls]Sheet1'!A1
So try doubling the single quotes.
|