Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble writing quotes " to file with WRITELINE

Status
Not open for further replies.

CGehlhausen

Programmer
Dec 17, 2004
14
US
I seem to have stumbled upon a problem creating an html file programatically with Excel VBA.

I'm taking information filled out in Excel sheets and using it to create an html text file, mainly using WRITE and WRITELINE.

Unfortunately the context requires using quotes around the text being written to the file, so if my text also has quotes in the middle of it, then VBA causes an error.

For example, the WRITE command in the following script would hang it up:

' Create new file
Set fs = CreateObject("Scripting.FileSystemObject")
Set newhtml = fs.CreateTextFile("C:\HTML.txt", True, True)
newhtml.Write ("<p style="text-align: left;"><strong>")
newhtml.Close


I know there should be a way around this using alternate characters or a syntax change, but I can't seem to find it in the VBA language reference.

Any suggestions would be greatly appreciated!



All's well that Ends!
 
Either:
newhtml.Write ("<p style=""text-align: left;""><strong>")

or:
newhtml.Write ("<p style='text-align: left;'><strong>")


Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
By the way, I did try using double quotes "" and also tried substituting parenthesis () and brackets [] in place of the ones around the text, but neither one worked.

I even tried putting an ampersand & in front of the middle quotes, but that didn't work either.

There's got to be a little VBA trick somewhere...


All's well that Ends!
 
What about using chr(34)?

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top