Re: vbscript to save file to a folder under user profile
- From: "ekkehard.horner" <ekkehard.horner@xxxxxxxx>
- Date: Tue, 12 Feb 2008 22:54:33 +0100
Pegasus (MVP) schrieb:
"Chris" <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:CA69421A-3A26-439E-A6A7-0A0557B93991@xxxxxxxxxxxxxxxx[...]
[...]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 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
As there seems to be noise on this line already, I'd like to add some of my own:
(1) Using Word to create the different versions of the info is certainly a very
good idea, but I had problems feeding a plain filename to Word. So maybe
const Name = "txthtmrtf" ' "..\data\txthtmrtf" "d:\Test" <-- no . here!
...
sFSpec = objFSO.GetAbsolutePathname( Name ) & "."
...
Set OutputStream = objFSO.CreateTextFile(Name & "txt")
...
objDoc.SaveAs sFSpec & "rtf", rtf
objDoc.SaveAs sFSpec & "htm", htm
could make the script less surprising.
(2) "OutputStream.WriteLine(Line1)" is bad/misleading VBScript. Parameter
list () aren't allowed when calling a Sub in this language. The engine
doesn't complain, because it thinks the programmer wanted to pass the
single parameter per value, but this isn't intended here.
.
- Follow-Ups:
- References:
- Re: vbscript to save file to a folder under user profile
- From: Pegasus \(MVP\)
- Re: vbscript to save file to a folder under user profile
- From: Chris
- Re: vbscript to save file to a folder under user profile
- From: Franz aRTiglio
- Re: vbscript to save file to a folder under user profile
- From: Pegasus \(MVP\)
- Re: vbscript to save file to a folder under user profile
- From: Franz aRTiglio
- Re: vbscript to save file to a folder under user profile
- From: Pegasus \(MVP\)
- Re: vbscript to save file to a folder under user profile
- From: Franz aRTiglio
- Re: vbscript to save file to a folder under user profile
- From: Pegasus \(MVP\)
- Re: vbscript to save file to a folder under user profile
- Prev by Date: Re: vbscript to save file to a folder under user profile
- Next by Date: Re: SizeToContent for IE
- Previous by thread: Re: vbscript to save file to a folder under user profile
- Next by thread: Re: vbscript to save file to a folder under user profile
- Index(es):
Relevant Pages
|