![]() |
Displaying a file and writing in vbscript
I want to access a file that already has data in it and I want to be able to edit or write information underneath the data? here is what I have so far
Code:
Option Explicit |
Re: Displaying a file and writing in vbscript
Okay I figured how to get it to read but its not displaying the message
Code:
Set objFSO = CreateObject("Scripting.FileSystemObject") |
Re: Displaying a file and writing in vbscript
Hi,
The approach you used first is simple and correct ! The code works perfectly fine for me, I just had to make a small change. The only thing is changed is the path : "C:\windows\system32\drivers\etc\hosts.txt", 'cuz there is no such file ! The correct path should be : "C:\windows\system32\drivers\etc\hosts" Try it ;) |
Re: Displaying a file and writing in vbscript
Got it thx ;)
|
Re: Displaying a file and writing in vbscript
Hey there I was wondering how I can append, basically add text to an already written document for example I found this code but I am not understanding how it works:
Code:
Thanks for your help |
Re: Displaying a file and writing in vbscript
Ok .. lemme explain the whole code.
Code: VB
Code: VB
Now, about your question .. "I don't understand the results of this and what is the need for strDirectory when you can go immediately to the source." Well, yeah you can go immediately to the source if it exists, else you would end up getting a run-time error that the specified path was not found ! Code: VB
Always remember to check for paths before trying to access them, that would ensure smooth and error-free running of your program. Code: VB
Code: VB
Code: VB
I hope things are clear to you now. No probs if not, keep posting :) |
Re: Displaying a file and writing in vbscript
Gosh your a genius I was looking deeply further and I found something simpler to write the text i need:
Code:
I am not quite sure how to fix can you help me. Thank you so much I really do appreciate the help. |
Re: Displaying a file and writing in vbscript
Nevermind but I was wondering what is the code for a newline? Not for html but for regular
|
Re: Displaying a file and writing in vbscript
Quote:
(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
Quote:
For example : (1) The output of : Code: VB
Code:
I am Saswat PadhiCode: VB
Code:
I am |
| All times are GMT +5.5. The time now is 11:38. |