Re: vbscript to save file to a folder under user profile




"Chris" <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:CA69421A-3A26-439E-A6A7-0A0557B93991@xxxxxxxxxxxxxxxx
I'm sorry if I started anything unnecessary. Both of you have been very
helpful. Can I ask another favor? As you know I don't know much about
scripting. Here is my situation.

Our Database developer will write a program to query our SQL database and
return values for several variables, such as first name, last name, title
and
phone #, etc, and pass it onto a script (my resposibility) to write it to
desktop during user logon under c:\documents and
settings\<userid>\application data\microsoft\signatures with three format,
htm, rtf and txt. Name will be at first line and phone # will be at
second
line. I tried to write a subroutine using an smaple I got from Internet
but
all I got are errors.

So, could you please write a sample script for me if it's not too much
work?
Or send me a better sample so I can work on it myself?

Thanks in advance.


I wouldn't worry too much about the noise on the line.
Here is a script that should give you what you need:

const rtf = 6
const htm = 8
const Name = "d:\Test."
const Line1 = "Franz Artiglio"
const Line2 = "+20 3 9456 7712"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWord = CreateObject("Word.Application")
Set OutputStream = objFSO.CreateTextFile(Name & "txt")

OutputStream.WriteLine(Line1)
OutputStream.WriteLine(Line2)
OutputStream.close

Set objDoc = objWord.Documents.Open(Name & "txt")
objDoc.SaveAs Name & "rtf", rtf
objDoc.SaveAs Name & "htm", htm
objDoc.Close
objWord.Quit


.



Relevant Pages