2013年4月4日 星期四

VBA - Write & Print Different in (.TXT) FILE


VBA CODE "

Sub WriteToATextFile()
'first set a string which contains the path to the file you want to create.
'this example creates one and stores it in the root directory

 MyFile = ActiveWorkbook.Path & "\" & "whateveryouwant.txt"
'set and open file for output
fnum = FreeFile()
Open MyFile For Output As fnum
'write project info and then a blank line. Note the comma is required
Write #fnum, "I wrote this"
Print #fnum, Sheets("Sheet1").Range("a1")
'use Print when you want the string without quotation marks
Print #fnum, "I printed this OK"
Close #fnum
End Sub

OUTPUT FILE ( whateveryouwant.txt )

"I wrote this"
tooltips[0]=["xman.jpg", "G1(270),G2(198)(2nd)(paid5.0)<br /> <B>G3</B>(b75),G4(530)", {background:"#FFFFFF", color:"black", border:"5px ridge darkblue"}]
I printed this OK


Different in with / without quotation marks

沒有留言:

張貼留言