Quote:
Originally Posted by shadowcat2021
Gosh your a genius I was looking deeply further and I found something simpler to write the text i need:
Code:
Dim fiParagraph
Dim fsoParagraph
set fsoParagraph = CreateObject("Scripting.FileSystemObject")
set fiParagraph = fsoParagraph.OpenTextFile(filelocation, 2, true)
if err.number = 0 then
fiMessage.write vendorparagraph
fiMessage.close
end if
set fiMessage = nothing
set fsoMessage = nothing
Now I placed my own file where the
filelocation is but an error comes up with
Object Required: fiMessage
I am not quite sure how to fix can you help me. Thank you so much I really do appreciate the help.
Check your code :
(1)
fiMessage is undeclared and un-initialized.
(2)
vendorparagraph is undeclared an un-initialized.
(3)
filelocation is undeclared an un-initialized.
(4)
fsoMessage is undeclared and un-initialized.
Even if you change
filelocation to some "real" path, what about the rest 2 problems ?
Get rid of
fiMessage at all. You're already using a text-stream as
fiParagraph. So, write your text through it.
And. you are opening the stream in mode 2 which means for writing it fresh (not appending).
And do remember to change
vendorparagraph to some real text.
A working copy of your code might look like :
Code: VB
Dim fiParagraph
Dim fsoParagraph
set fsoParagraph = CreateObject("Scripting.FileSystemObject")
set fiParagraph = fsoParagraph.OpenTextFile("C:\test.txt", 2, true)
if err.number = 0 then
fiParagraph.write "Saswat Padhi"
fiParagraph.close
else
msgbox "Error opening stream !"
end if
set fiParagraph = nothing
set fsoParagraph = nothing
Quote:
Originally Posted by shadowcat2021
Nevermind but I was wondering what is the code for a newline? Not for html but for regular
To put a new line in a file, through VB, you can use
vbCrlLf.
For example :
(1) The output of :
Code: VB
fiParagraph.write "I am "+"Saswat Padhi"
is :
(2) The output of :
Code: VB
fiParagraph.write "I am "+vbCrLf+"Saswat Padhi"
is :