Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Single quotes in OnAction property of a button
I have VBA code that adds buttons to a worksheet. In one instance I add a
button and I assign a macro whereby it opens Windows Explorer to that file: ..OnAction = "'OpenExplorer """ & strMyFileName & """'" The problem I have is that some files have apostrophe's in the file name. And seeing that I need to put the OnAction property inside double-quotes and the macro itself inside single quotes, I have a problem. Whenever a file has a single quote in its name the code gives me an error. Any suggestions? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Single quotes in OnAction property of a button
Use replace and change one single quote to two single quotes
strMyFileName = replace(strMyFileName,"'","''") "Ray C" wrote: I have VBA code that adds buttons to a worksheet. In one instance I add a button and I assign a macro whereby it opens Windows Explorer to that file: .OnAction = "'OpenExplorer """ & strMyFileName & """'" The problem I have is that some files have apostrophe's in the file name. And seeing that I need to put the OnAction property inside double-quotes and the macro itself inside single quotes, I have a problem. Whenever a file has a single quote in its name the code gives me an error. Any suggestions? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
passing parameters to function assigned to button property onAction?? | Excel Programming | |||
Problem with Button OnAction property... | Excel Programming | |||
Button Selection OnAction property | Excel Programming | |||
Find OnAction property | Excel Programming |