Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Quote in filename causes problem with Application.Run

I am having problems trying to call a function when the
workbook name contains a quotation mark. The code which
works when there is no quote in the name is:

WbVer = Application.Run("'" &
Application.ActiveWorkbook.Name & "'!VerifySS", SSVerKey)

VerifySS is a public function within a module in the
activeworkbook file. It is being called by code in an xla
which is activated by a toolbar button.

This works when there is no quote in the filename but the
string gets understandable confused by a quote in the
name. (eg "O'Neil File.xls") I tried to surround it with
double quotes, ['s etc but cannot get it working as any
time I build the run command adding the !functionname, it
becomes a string and the quote gets interpreted.

I would really appreciate any advice on this. As a last
resort, I can block file names being created with a quote
but the users tell me they need to do this.

Thanks and regards
Carolyn
Any help in


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Quote in filename causes problem with Application.Run

Try this:

sStr = ActiveWorkbook.Name
sStr = Application.Substitute(sStr,"'","''")
WbVer = Application.Run("'" & _
sStr & "'!VerifySS", SSVerKey)


replace each single quote with two single quotes within the string itself.

--
Regards,
Tom Ogilvy



"Carolyn" wrote in message
...
I am having problems trying to call a function when the
workbook name contains a quotation mark. The code which
works when there is no quote in the name is:

WbVer = Application.Run("'" &
Application.ActiveWorkbook.Name & "'!VerifySS", SSVerKey)

VerifySS is a public function within a module in the
activeworkbook file. It is being called by code in an xla
which is activated by a toolbar button.

This works when there is no quote in the filename but the
string gets understandable confused by a quote in the
name. (eg "O'Neil File.xls") I tried to surround it with
double quotes, ['s etc but cannot get it working as any
time I build the run command adding the !functionname, it
becomes a string and the quote gets interpreted.

I would really appreciate any advice on this. As a last
resort, I can block file names being created with a quote
but the users tell me they need to do this.

Thanks and regards
Carolyn
Any help in




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Quote in filename causes problem with Application.Run

Thank you so much. It works a treat!


-----Original Message-----
Try this:

sStr = ActiveWorkbook.Name
sStr = Application.Substitute(sStr,"'","''")
WbVer = Application.Run("'" & _
sStr & "'!VerifySS", SSVerKey)


replace each single quote with two single quotes within

the string itself.

--
Regards,
Tom Ogilvy



"Carolyn" wrote in

message
...
I am having problems trying to call a function when the
workbook name contains a quotation mark. The code which
works when there is no quote in the name is:

WbVer = Application.Run("'" &
Application.ActiveWorkbook.Name & "'!VerifySS",

SSVerKey)

VerifySS is a public function within a module in the
activeworkbook file. It is being called by code in an

xla
which is activated by a toolbar button.

This works when there is no quote in the filename but

the
string gets understandable confused by a quote in the
name. (eg "O'Neil File.xls") I tried to surround it

with
double quotes, ['s etc but cannot get it working as any
time I build the run command adding the !functionname,

it
becomes a string and the quote gets interpreted.

I would really appreciate any advice on this. As a last
resort, I can block file names being created with a

quote
but the users tell me they need to do this.

Thanks and regards
Carolyn
Any help in




.

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
MSN Money Stock Quote Problem Mike T[_2_] Excel Worksheet Functions 1 October 30th 07 09:11 PM
problem with msn money stock quote add in [email protected] Excel Worksheet Functions 2 July 15th 05 01:00 AM
Problem with Application.Width Leo Excel Programming 2 February 2nd 04 09:22 PM
Application Problem Stuart[_10_] Excel Programming 7 November 16th 03 05:44 PM
Typing a quote character Vs pasting a quote character= whathappens to the resulting CSV? Interesting!! Jon Peltier[_3_] Excel Programming 0 August 3rd 03 02:22 AM


All times are GMT +1. The time now is 02:25 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"