Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.fox.programmer.exchange
external usenet poster
 
Posts: 14
Default can't use Application.Run() with apostrophe in file name

I need to use the application.run method to invoke macros in workbooks I
create. Unfortunately, the workbooks can contain apostrophes in the file
name.

I tried double quoting the filename if it contains an apostrophe, but
that didn't work:

*double quote the file name if it contains an apostrophe
lcCAMNotebookFileName = loCAMNotebook.Name
IF CHR(39) $ lcCAMNotebookFileName
lcMacroName = [''] + lcCAMNotebookFileName + [''] + "!" +
EXCEL_MACRO_NAME
ELSE
lcMacroName = ['] + lcCAMNotebookFileName + ['] + "!" +
EXCEL_MACRO_NAME
ENDIF

*--run the Excel formatting macros
TRY
loExcelApp.Run( lcMacroName )
CATCH TO loErr
brserror( "couldn't find macro " + EXCEL_MACRO_NAME)
SET STEP ON
DEBUGOUT loerr.ErrorNo
DEBUGOUT loerr.Message
ENDTRY
  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.fox.programmer.exchange
external usenet poster
 
Posts: 2,253
Default can't use Application.Run() with apostrophe in file name

no brackets
single quotes outside
repeat existing singlequote

Application.Run "'no''show.xls'!myProc"





--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Woody wrote :

I need to use the application.run method to invoke macros in
workbooks I create. Unfortunately, the workbooks can contain
apostrophes in the file name.

I tried double quoting the filename if it contains an apostrophe, but
that didn't work:

*double quote the file name if it contains an apostrophe
lcCAMNotebookFileName = loCAMNotebook.Name
IF CHR(39) $ lcCAMNotebookFileName
lcMacroName = [''] + lcCAMNotebookFileName + [''] + "!" +
EXCEL_MACRO_NAME
ELSE
lcMacroName = ['] + lcCAMNotebookFileName + ['] + "!" +
EXCEL_MACRO_NAME
ENDIF

*--run the Excel formatting macros
TRY
loExcelApp.Run( lcMacroName )
CATCH TO loErr
brserror( "couldn't find macro " + EXCEL_MACRO_NAME)
SET STEP ON
DEBUGOUT loerr.ErrorNo
DEBUGOUT loerr.Message
ENDTRY

  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.fox.programmer.exchange
external usenet poster
 
Posts: 1,120
Default can't use Application.Run() with apostrophe in file name

Doubling-up the apostrophe works for me. Don't forget leading and trailing
apostrophes as well

Application.Run "'VPinMame Roms''99.xls'!Bob()"

--
HTH

Bob Phillips

"Woody" wrote in message
.119...
I need to use the application.run method to invoke macros in workbooks I
create. Unfortunately, the workbooks can contain apostrophes in the file
name.

I tried double quoting the filename if it contains an apostrophe, but
that didn't work:

*double quote the file name if it contains an apostrophe
lcCAMNotebookFileName = loCAMNotebook.Name
IF CHR(39) $ lcCAMNotebookFileName
lcMacroName = [''] + lcCAMNotebookFileName + [''] + "!" +
EXCEL_MACRO_NAME
ELSE
lcMacroName = ['] + lcCAMNotebookFileName + ['] + "!" +
EXCEL_MACRO_NAME
ENDIF

*--run the Excel formatting macros
TRY
loExcelApp.Run( lcMacroName )
CATCH TO loErr
brserror( "couldn't find macro " + EXCEL_MACRO_NAME)
SET STEP ON
DEBUGOUT loerr.ErrorNo
DEBUGOUT loerr.Message
ENDTRY



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New Application opening for each file Michelle Excel Discussion (Misc queries) 1 August 3rd 09 12:42 PM
New Application opening for each file Michelle Setting up and Configuration of Excel 1 August 3rd 09 12:42 PM
opening a file in Excel starts application but dose not open file Bob Shelton Excel Discussion (Misc queries) 1 July 2nd 08 07:51 PM
Application opens but the file does not? David Renehan Excel Discussion (Misc queries) 17 January 15th 07 07:06 PM
xcel file icon opens application but not file. RayG Excel Discussion (Misc queries) 1 June 7th 06 07:21 PM


All times are GMT +1. The time now is 05:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"