Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


File Creation

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,29213
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> File Creation
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2 3   next >   >>
Login
Message << Older Topic   Newer Topic >>
 File Creation - 12/20/2005 12:27:28 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Hey guys,

I have a simple thing that I would like to achive.

From time to time I have to create SCR files that contain the necessary login and upload information for our stores.

What I would like to is create a script that will ask a couple of simple questions, ie user name, store number and then populate the fields and output and save the completed SCR file.

Any help would be greatly appreciated.
 
 
Post #: 1
 
 RE: File Creation - 12/20/2005 1:28:02 PM   
  Cybex


Posts: 412
Score: 0
Joined: 9/14/2005
From: Florida
Status: offline
Not knowing what is in or how the SCR files are structured, I would say read up on "CreateTextFile" and then use input boxes and "writeline" to create your file.  Search this board, it is an easy starter script to do.

Good luck! Ask for help and we will assist.

Cybex

_____________________________

Common sense is not so common.

(in reply to Navarre)
 
 
Post #: 2
 
 RE: File Creation - 12/20/2005 1:39:30 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Sorry my fault, my brain is in neutral at the moment.

The SCR files are just TXT files with the extension changed to SCR.  This is so that we can use them with our FTP script.  On the inside of the file is the login information, the files to upload, and the FTP address.

(in reply to Cybex)
 
 
Post #: 3
 
 RE: File Creation - 12/21/2005 12:49:12 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Here is an example of the format that I am trying to achieve.

open x.x.x.x   <--- FTP Server to connect to
Domain\User    <-- Domain and user name of the person trying to connect
password         <-- the password that they are using
bi
cd \comms\oz             <-- Standard text from here
lcd c:\arrow\comms
mput arr??r??.xfr
cd \comms\oz\upload
mget ARR??H80.XFR
cd \comms\oz
lcd c:\arrow\arr@data
mput r??-dcom.txt
mput r??-ucom.txt
lcd c:\data\forms
mput ???_w1.xls
lcd c:\temp
cd \comms\files
mget *.*              <-- Standard text ends here
cd \comms\files\04  <-- the 04 is a shop number that I want to have the script put that in from a text box.
mget *.*
quit

In essence all this is is an instruction that the FTP command uses of where and what to upload and download, at the end I need to have the file saved as Comms.scr

(in reply to Navarre)
 
 
Post #: 4
 
 RE: File Creation - 12/26/2005 8:58:28 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Navarre,

(1) Write a sample file (comms.001) with 'real' data:


      

(2) Replace the changing data with placeholders (§<Name>§) and save
    it to comms.000


      

(3) Write mcomms.vbs like this:


      

(4) Plan for the solution 'in principle':
    (a) get placeholders (markers) from comms.000 into a Dictionary
        (markers as keys)
    (b) set dictionary values as appropriate (cf. comms.001)
    (c) replace markers with values
    (d) result should be equal to comms.001

(5) Add Function doMain00() like this:


      

(6) Enhance it:


      

(7) Of cource, we need values:

Change

  For Each sKey In dicMarkers.Keys
      WScript.Echo sKey
  Next

To

  For Each sKey In dicMarkers.Keys
      WScript.Echo "dicMarkers( """ + sKey + """ ) = """""
  Next

And use the output to enhance doMain00() further:


      

(8) Use doMain01() to come to grips with the arguments:


      

(9) Combine the code of doMain01 and doMain00 into doMain()

(10) Think about your specs: Should the dictionary values come from
     a file (which format?), would you prefere a GUI interface (hta?)

(in reply to Navarre)
 
 
Post #: 5
 
 RE: File Creation - 12/27/2005 10:22:28 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
What I was looking at was either something like a HTA to ask me the questions for the information that I want to set up, ie the FTP site to upload to, the store number, the store username, and the store password.

As the rest of the text is all standard and could be made part of the output.

(in reply to ehvbs)
 
 
Post #: 6
 
 RE: File Creation - 12/27/2005 10:31:12 AM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thanks for the help, but being the giant spaz that I am, I think I put it together wrong.

Here is the script that I ended up with, if I made a mistake (which I more than likely did), can you let me know where I went wrong. 

' ############################################################################
''# mcomms.vbs - commandline tool to create .SCR files
' ============================================================================
' <your std header, copyright, comments, documentation here>
' ############################################################################

Option Explicit ''< variables must be declared before use

' ############################################################################
''# main - back to OS with return value of selected function
' ----------------------------------------------------------------------------
' reorder/(un)comment to select code to run (doMain will be production code;
' test functions can be removed when all is done)
' ############################################################################

WScript.Quit
  Function doMain00()
  Dim nRVal      : nRVal          = 1
  Dim oFS        : Set oFS        = CreateObject( "Scripting.FileSystemObject" )
  Dim dicMarkers : Set dicMarkers = CreateObject( "Scripting.Dictionary"       )
  Dim sText0     : sText0         = oFS.OpenTextFile( "comms.000" ).ReadAll()
  Dim sText1     : sText1         = oFS.OpenTextFile( "comms.001" ).ReadAll()
  Dim oRE        : Set oRE        = New RegExp
  Dim oMTS
  Dim oMT
  Dim sKey

  oRE.Pattern = "§\w+§" ' get (all) words between §s
  oRE.Global  = True

  Set oMTS = oRE.Execute( sText0 )
  For Each oMT In oMTS
      dicMarkers.Add oMT.Value, ""
  Next

  For Each sKey In dicMarkers.Keys
      WScript.Echo "dicMarkers( """ + sKey + """ ) = """""
  Next

  dicMarkers( "§HOST§"    ) = "123.123.123.123"
  dicMarkers( "§DomUser§" ) = "niamod/resu"
  dicMarkers( "§PassW§"   ) = "secret"
  dicMarkers( "§ShopNum§" ) = "04"

  For Each sKey In dicMarkers.Keys
      sText0 = Replace( sText0, sKey, dicMarkers( sKey ) )
  Next

   If sText0 = sText1 Then
      WScript.Echo "ok"
   Else
      WScript.Echo "failure"
      WScript.Echo sText0
   End If

End Function

' ============================================================================
''= doMain01 - testing args
' ============================================================================

Function doMain01()
   Dim nRVal      : nRVal          = 1
   Dim dicMarkers : Set dicMarkers = CreateObject( "Scripting.Dictionary"       )
   Dim nIdx
   Dim sKey

   dicMarkers.Add "§HOST§"   , ""
   dicMarkers.Add "§DomUser§", ""
   dicMarkers.Add "§PassW§"  , ""
   dicMarkers.Add "§ShopNum§", ""

   If 4 = WScript.Arguments.Count Then
      For nIdx = 0 To 3
          Select Case nIdx
            Case 0
             dicMarkers( "§HOST§"    ) = WScript.Arguments( nIdx )
            Case 1
              dicMarkers( "§DomUser§" ) = WScript.Arguments( nIdx )
            Case 2
             dicMarkers( "§PassW§"   ) = WScript.Arguments( nIdx )
            Case 3
              dicMarkers( "§ShopNum§" ) = WScript.Arguments( nIdx )
          End Select
      Next
      nRVal = 1
      For Each sKey In dicMarkers.Keys
          WScript.Echo "dicMarkers( """ + sKey + """ ) = """ + dicMarkers( sKey ) + """"
      Next
   Else
      WScript.Echo "Usage: mcomms.vbs <host>, <domuser>, <passw>, <shop>"
   End If

   doMain01 = nRVal
End Function

(in reply to ehvbs)
 
 
Post #: 7
 
 RE: File Creation - 12/27/2005 7:57:43 PM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Navarre,

you won't get far if you change my script to "WScript.Quit". But nevermind, if you want
a HTA:


      

This bare bones code handles the Host only, but I trust you can add the single line edit boxes easily.
If not, just say so.

(in reply to Navarre)
 
 
Post #: 8
 
 RE: File Creation - 12/27/2005 10:23:02 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thanks for that, I did not mean to change the other code but I am real newbie to coding so at this time I am struggling through.

Thanks again for your help, now I will just have to look at adding the extra bits to prompt for password and login.

(in reply to ehvbs)
 
 
Post #: 9
 
 RE: File Creation - 1/1/2006 3:44:45 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Again thanks for the help, I have been trying to add necessary code so that is loads the extra bits for the user name and so on, but have not had any luck.

If you could let me know how to change it so that it adds the rest in that would be great.

(in reply to ehvbs)
 
 
Post #: 10
 
 RE: File Creation - 1/1/2006 6:30:39 PM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Navarre,

in addition to the HOST item in my code you need three more items
DOMUSER, PASSW, and SHOPNUM. So:

(1) Take the HTML code for HOST

    <tr><td>Host</td><td><input id = "sleHost" type = "TEXT"></td></tr>

    and add

    <tr><td>Dom/Usr</td>    <td><input id = "sleDomUsr"  type = "TEXT"></td></tr>
    <tr><td>Password</td>   <td><input id = "slePassW"   type = "TEXT"></td></tr>
    <tr><td>Shop number</td><td><input id = "sleShopNum" type = "TEXT"></td></tr>

(2) Check the .hta - does it look right?

(3) Take the GetValue code for HOST

      If "" = Trim( sleHost.Value ) Then sleHost.Value = "123.123.123.123"

    and add

      If "" = Trim( sleDomUsr.Value  ) Then sleDomUsr.Value  = "niamod/resu"
      If "" = Trim( slePassW.Value   ) Then slePassW.Value   = "secret"
      If "" = Trim( sleShopNum.Value ) Then sleShopNum.Value = "04"

(4) Check the .hta - no syntax errors?

(5) Add the three new Values to the call and the definition of doTempl()

      doTempl( sleHost.Value )
      doTempl sleHost.Value, sleDomUsr.Value, slePassW.Value, sleShopNum.Value

    By getting rid of the () you correct the blunder I'm really ashamed of:
    Parameters to Subs must not be put into (). "doTempl( sleHost.Value )"
    my look like a simple Sub call, but is a Sub call with the single parameter
    "sleHost.Value" promoted to Const: that shound be written as
    "doTempl (sleHost.Value)".

      Sub doTempl( sHost )
      Sub doTempl( sHost, sDomUsr, sPassW, sShopNum )

(6) Check the .hta - no syntax errors?

(7) Use the new paramters - change

     dicMarkers.Add "§HOST§"   , sHost
     dicMarkers.Add "§DomUser§", "niamod/resu" ' will be replaced
     dicMarkers.Add "§PassW§"  , "secret"      ' will be replaced
     dicMarkers.Add "§ShopNum§", "04"          ' will be replaced

    to

     dicMarkers.Add "§HOST§"   , sHost
     dicMarkers.Add "§DomUser§", sDomUsr
     dicMarkers.Add "§PassW§"  , sPassW
     dicMarkers.Add "§ShopNum§", sShopNum

(6) Check the .hta - expected results in comms.scr, if you put some
    new values in the SingleLineEditControls?

(in reply to Navarre)
 
 
Post #: 11
 
 RE: File Creation - 1/1/2006 8:06:52 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Have I put this together correctly as I keep getting object require slehost.


<html>
<head>
  <hta:application id = "mcomms" />
   <title>tbox</title>
   <meta http-equiv = "content-script-type" content = "text/vbscript"/>
   <script language = "VBScript" type = "text/vbscript" >
'<![CDATA[

Option Explicit

''= read/write access TEXTs, call doTempl with marker value(s)
' ============================================================================
Sub doIt()
  Dim sleHost : Set sleHost = document.getElementById( "sleHost.Value" )

  If "" = Trim( sleHost.Value    ) Then sleHost.Value = "123.123.123.123"
  If "" = Trim( sleDomUsr.Value  ) Then sleDomUsr.Value  = "niamod/resu"
  If "" = Trim( slePassW.Value   ) Then slePassW.Value   = "secret"
  If "" = Trim( sleShopNum.Value ) Then sleShopNum.Value = "04"

  doTempl sleHost.Value, sleDomUsr.Value, slePassW.Value, sleShopNum.Value

End Sub

''= read Template, replace markers, write result
' ============================================================================

Sub doTempl( sHost, sDomUsr, sPassW, sShopNum )
  Dim oFS        : Set oFS        = CreateObject( "Scripting.FileSystemObject" )
  Dim dicMarkers : Set dicMarkers = CreateObject( "Scripting.Dictionary"       )
  Dim sDir       : sDir           = Mid( document.url, Len( "file://" ) + 1 )
                   sDir           = oFS.GetParentFolderName( sDir ) + "\"
  Dim sText0     : sText0         = oFS.OpenTextFile(   sDir + "comms.000" ).ReadAll()
  Dim oTSRes     : Set oTSRes     = oFS.CreateTextFile( sDir + "comms.scr" )
  Dim sKey

    dicMarkers.Add "§HOST§"   , sHost
    dicMarkers.Add "§DomUser§", sDomUsr
    dicMarkers.Add "§PassW§"  , sPassW
    dicMarkers.Add "§ShopNum§", sShopNum

  For Each sKey In dicMarkers.Keys
      sText0 = Replace( sText0, sKey, dicMarkers( sKey ) )
  Next

  oTSRes.Write sText0
  oTSRes.Close
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================
Sub reloadHTA()
  location.reload( True )
End Sub

']]>
  </script>
</head>
<body>
  <table border = "1">
   <tr><td>Host</td><td><input id = "sleHost" type = "TEXT"></td></tr>
  </table>
  <br />
  <table border = "1">
   <tr><td>Domain User</td><td><input id = "sleDomUser" type = "TEXT"></td></tr>
  </table>
  <br />
  <table border = "1">
   <tr><td>Password</td><td><input id = "sleHost" type = "TEXT"></td></tr>
  </table>
  <br />
  <table border = "1">
   <tr><td>Shop Number</td><td><input id = "sleHost" type = "TEXT"></td></tr>
  </table>
  <br />
  <o:p>&nbsp;</o:p></p>
  <input type = "BUTTON" value = "Do It Now" onclick = "doIt()">
  <hr />
  <o:p>&nbsp;</o:p></p>
  <input type = "BUTTON" value = "Reload This Thing" onclick = "reloadHTA()">
</body>
</html>

(in reply to ehvbs)
 
 
Post #: 12
 
 RE: File Creation - 1/1/2006 8:45:37 PM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Navarre,

The first error is in your line:

   Dim sleHost : Set sleHost = document.getElementById( "sleHost.Value" )

This should read

   Dim sleHost : Set sleHost = document.getElementById( "sleHost" )

because we want the HTML Element named/ided(?) "sleHost" and definitely
not the element named by whatever this element contains (probably an empty
string; not a good name!).

The second error:

  <table border = "1">
   <tr><td>Password</td><td><input id = "sleHost" type = "TEXT"></td></tr>
  </table>
 
  Of course you may do want you want, but I didn't tell you to put each
  control into a table. If you followed my advice you'd have added something
  like
 
    <tr><td>Dom/Usr</td>    <td><input id = "sleHost"    type = "TEXT"></td></tr>
    <tr><td>Password</td>   <td><input id = "sleHost"    type = "TEXT"></td></tr>
    <tr><td>Shop number</td><td><input id = "sleHost"    type = "TEXT"></td></tr>

  Then it would have been obvious that you have to give suitable ids to the
  elements.

I overlooked that you either should add Dim/Set lines for the other elements
too

   Dim sleDomUsr  : Set sleDomUsr  = document.getElementById( "sleDomUsr"  )
   Dim slePassW   : Set slePassW   = document.getElementById( "slePassW"   )
   Dim sleShopNum : Set sleShopNum = document.getElementById( "sleShopNum" )

or get rid of all the Dim/Set lines. The first way is better, because it decouples
the names/ids of the HTML elements from your code; but you can get away without
VBScript variables for the elements, as long as you use "<id>.<method/property>"
with the correct <id>.
 

(in reply to Navarre)
 
 
Post #: 13
 
 RE: File Creation - 1/1/2006 9:12:50 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
I must be driving you up the wall.

I remodified the code as you specified and when I run the HTA comes up fine, but when I click the do it button I get an 'object required' on line 20 character 4.  Again I have put the full code in to make sure that I made the correct changes.

<html>
<head>
  <hta:application id = "mcomms" />
   <title>tbox</title>
   <meta http-equiv = "content-script-type" content = "text/vbscript"/>
   <script language = "VBScript" type = "text/vbscript" >
'<![CDATA[

Option Explicit

''= read/write access TEXTs, call doTempl with marker value(s)
' ============================================================================
Sub doIt()
  Dim sleHost    : Set sleHost    = document.getElementById( "sleHost"    )
  Dim sleDomUsr  : Set sleDomUsr  = document.getElementById( "sleDomUsr"  )
  Dim slePassW   : Set slePassW   = document.getElementById( "slePassW"   )
  Dim sleShopNum : Set sleShopNum = document.getElementById( "sleShopNum" )

  If "" = Trim( sleHost.Value    ) Then sleHost.Value = "123.123.123.123"
  If "" = Trim( sleDomUsr.Value  ) Then sleDomUsr.Value  = "niamod/resu"
  If "" = Trim( slePassW.Value   ) Then slePassW.Value   = "secret"
  If "" = Trim( sleShopNum.Value ) Then sleShopNum.Value = "04"

  doTempl sleHost.Value, sleDomUsr.Value, slePassW.Value, sleShopNum.Value

End Sub

''= read Template, replace markers, write result
' ============================================================================

Sub doTempl( sHost, sDomUsr, sPassW, sShopNum )
  Dim oFS        : Set oFS        = CreateObject( "Scripting.FileSystemObject" )
  Dim dicMarkers : Set dicMarkers = CreateObject( "Scripting.Dictionary"       )
  Dim sDir       : sDir           = Mid( document.url, Len( "file://" ) + 1 )
                   sDir           = oFS.GetParentFolderName( sDir ) + "\"
  Dim sText0     : sText0         = oFS.OpenTextFile(   sDir + "comms.000" ).ReadAll()
  Dim oTSRes     : Set oTSRes     = oFS.CreateTextFile( sDir + "comms.scr" )
  Dim sKey

    dicMarkers.Add "§HOST§"   , sHost
    dicMarkers.Add "§DomUser§", sDomUsr
    dicMarkers.Add "§PassW§"  , sPassW
    dicMarkers.Add "§ShopNum§", sShopNum

  For Each sKey In dicMarkers.Keys
      sText0 = Replace( sText0, sKey, dicMarkers( sKey ) )
  Next

  oTSRes.Write sText0
  oTSRes.Close
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================
Sub reloadHTA()
  location.reload( True )
End Sub

']]>
  </script>
</head>
<body>
  <table border = "1">
   <tr><td>Host</td>       <td><input id = "sleHost"    type = "TEXT"></td></tr>
   <tr><td>Dom/Usr</td>    <td><input id = "sleHost"    type = "TEXT"></td></tr>
   <tr><td>Password</td>   <td><input id = "sleHost"    type = "TEXT"></td></tr>
   <tr><td>Shop number</td><td><input id = "sleHost"    type = "TEXT"></td></tr>
  </table>
  <o:p>&nbsp;</o:p></p>
  <input type = "BUTTON" value = "Do It Now" onclick = "doIt()">
  <hr />
  <o:p>&nbsp;</o:p></p>
  <input type = "BUTTON" value = "Reload This Thing" onclick = "reloadHTA()">
</body>
</html>


Line 20 is the    If "" = Trim( sleDomUsr.Value  ) Then sleDomUsr.Value  = "niamod/resu"

Any ideas

(in reply to ehvbs)
 
 
Post #: 14
 
 RE: File Creation - 1/1/2006 9:38:45 PM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Navarre,

no, I'm not 'up the wall'. I'm sitting at my desk, slightly embarrassed/ashamed, because I didn't
explain clearly what I meant. The thing is: You have to identify the HTML elements you are going
to use by giving them suitable ids. So the lines should read:

   <tr><td>Host</td>       <td><input id = "sleHost"    type = "TEXT"></td></tr>
   <tr><td>Dom/Usr</td>    <td><input id = "sleDomUsr"  type = "TEXT"></td></tr>
   <tr><td>Password</td>   <td><input id = "slePassW"   type = "TEXT"></td></tr>
   <tr><td>Shop number</td><td><input id = "sleShopNum" type = "TEXT"></td></tr>

The lines in my last posting (with all ids = "sleHost") were meant to show you that you
increase your chances of seeing typical 'program-by-copy-and-paste' errors , if you
keep such lines close together and invest some time in formatting/proper indenting.

I'm sorry about misleading you and I hope I don't drive you up the wall.

(in reply to Navarre)
 
 
Post #: 15
 
 RE: File Creation - 1/1/2006 10:04:07 PM   
  Navarre

 

Posts: 90
Score: 0
Joined: 10/19/2005
Status: offline
Thanks for that, worked like a charm.

On another side issue, I was just thinking of another way of it getting the correct information.  Would it be possible to have it read the information from an excel sheet and then save the comms.scr file to a subdirectory based upon the store number.  I believe something like that is possible, am I right in assuming this.

One other thing that I am looking at doing.   I am trying to find a way to  rename files that get loaded onto a server every night based upon other files that get uploaded with them.

For example some of the files we get are as follows -

r29-dcom.txt, arr56r29.xfr
r15-dcom.txt, arr22r15.xfr

Now I need to rename the r29-dcom.txt and r15-dcom.txt files to have the number that the XFR files has.  So after renaming them I would end up with the following.

r29-dcom56.txt, arr56r29.xfr
r15-dcom22.txt, arr22r15.xfr


There are quite a few files that I have to do this for on an on going basis and I need a way to speed it.  The big issue is that the number in the arr56r29.xfr will increment everyday until it reaches 00 and
then start again, so tomorrow would be arr57r29.xfr.

The only reason I ask is that I have been looking around I have found ways of changing parts of the name, extensions, or adding dates.  But not based upon other files.

Again thanks for your help, you have been great help.

Tim Wallace

(in reply to ehvbs)
 
 
Post #: 16
 
 RE: File Creation - 1/2/2006 4:34:20 AM   
  ehvbs

 

Posts: 2012
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi Tim,

This doesn't look like the 'simple thing' you started this topic with anymore!
I will try to help you, but I can't promise you that I have time to spend in
the near future. Just now I'm between projects, but that can change any time.

My first advice: Try to split your tasks into simple subtasks and do some
experimenting guided by the VBScript Docs and sample code from this forum.
You may use the stategy of putting diffent Subs of (modified) sample code
in one .VBS file like I proposed in my first posting, or - if you don't like
the (un)comment approach - follow the proposal of mbouchard: use suitably
named stand alone .VBS files (in one directory and an editor which can
display more than one file at the same time).
By the way - what happens, if you start a script like this:
  cscript //X <script.vbs>
If this doesn't start a debugger, consider getting one (for your OS)
from MS and install it.

EXCEL
If you search this forum for "excel", "excel write", "excel ado" (with
or without specifying ehvbs as author) you'll get a lot of sample code
for and discussion about "getting data from excel". Try to come up with
a Sub that just opens your .XLS and WScript.Echos the first table row.

SAVING
Change

Sub doTempl( sHost, sDomUsr, sPassW, sShopNum )
  Dim oFS        : Set oFS        = CreateObject( "Scripting.FileSystemObject" )
  Dim dicMarkers : Set dicMarkers = CreateObject( "Scripting.Dictionary"       )
  Dim sDir       : sDir           = Mid( document.url, Len( "file://" ) + 1 )
                   sDir           = oFS.GetParentFolderName( sDir ) + "\"
  Dim sText0     : sText0         = oFS.OpenTextFile(   sDir + "comms.000" ).ReadAll()
  Dim oTSRes     : Set oTSRes     = oFS.CreateTextFile( sDir + "comms.scr" )
  Dim sKey

    dicMarkers.Add "§HOST§"   , sHost
    dicMarkers.Add "§DomUser§", sDomUsr
    dicMarkers.Add "§PassW§"  , sPassW
    dicMarkers.Add "§ShopNum§", sShopNum

  For Each sKey In dicMarkers.Keys
      sText0 = Replace( sText0, sKey, dicMarkers( sKey ) )
  Next

  oTSRes.Write sText0
  oTSRes.Close
End Sub

To

Sub doTempl( sHost, sDomUsr, sPassW, sShopNum )
  Dim oFS&n