Escaping Quotes problem

D

David

Hello, advice appreciated please.

I've got this line of VBA:

sScreenContents = Application.Substitute(sScreenContents, """", "\""")

The idea is to find any quotes in a string and escape them with a
backslash before outputting. The problem is that the output has

\""

rather than just the

\"

I was expecting, if I change the code to:

sScreenContents = Application.Substitute(sScreenContents, """", "\"")

the line is highlighted in red.

Any ideas of a way round this, or am I doing something wrong?

Thanks.
 
B

Bob Phillips

sScreenContents = Application.Substitute(sScreenContents, """", "\")


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

Try using the ascii value as per this:-

sScreenContents = Application.Substitute(sScreenContents, Chr(34), Chr(92))

I tested it and it works.

Regards,

OssieMac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top