ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Escaping Quotes problem (https://www.excelbanter.com/excel-programming/393488-escaping-quotes-problem.html)

David

Escaping Quotes problem
 
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.


Bob Phillips

Escaping Quotes problem
 
sScreenContents = Application.Substitute(sScreenContents, """", "\")


--
HTH

Bob

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

"David" wrote in message
ups.com...
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.




OssieMac

Escaping Quotes problem
 
Try using the ascii value as per this:-

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

I tested it and it works.

Regards,

OssieMac

"David" wrote:

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.




All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com