Re: vbscript to save file to a folder under user profile
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Wed, 13 Feb 2008 20:45:19 +0100
See below.
"Chris" <Chris@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E502E2AE-07A0-473E-B9B1-AB5CE58055D7@xxxxxxxxxxxxxxxx
Pegasus,
I tried your script and it works fine except one thing.
1. I got a popup windows "Covert File", asking "convert file from plain
text". If I click on OK, MS Word will open for each format (htm, txt and
rtf) then close. How can I make it silent so users don't need to click
OK?
I also hope the users don't even see MS Word popup.
Since I don't get a popup on my machine, I suspect that this is
something that is specific to the version of Word you use. I don't
think it has anything to do with the script. You can easily test it:
Use notepad.exe to create a text file, save it as "test.doc", then
type "Test.doc" at the Command Prompt. Do you get the conversion
prompt? If yes, ask an MS Word newsgroup how to suppress it.
2. Does it require MS Word? I have some users who might not
have MS Word on their machines.
Yes, it does.
3. how to save the files under user profile, such as c:\documents and
settings\<userid>\application data\microsoft\signatures.
Change
const Name = "d:\Test."
to
const Name = "c:\documents and settings\Chris\appl..\signatures\Test."
sorry to bug you.
"ekkehard.horner" wrote:
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.
.
- 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
- From: ekkehard.horner
- Re: vbscript to save file to a folder under user profile
- From: Chris
- Re: vbscript to save file to a folder under user profile
- Prev by Date: Re: Import and Insert data from email
- Next by Date: Re: Does Open File For Output As #1 work in VBS?
- Previous by thread: Re: vbscript to save file to a folder under user profile
- Next by thread: Shell.App in local zone
- Index(es):
Relevant Pages
|