Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't See the Forest for the Trees !!!

Status
Not open for further replies.

z2gary

Technical User
Mar 16, 2008
5
US
Hello:
My script does almost everything I want.
I pick the file I'm going to copy with the UserAccounts Dialog.
This file name is xclude.txt
I'm writing this out to another folder and adding a incrementing number to the end so I have multiple copies depending on what the user enters into the inputbox function.
It writes everything out correctly except for one thing.
It uses my variable name (strpath) instead of the name inside the variable which is (xclude.txt).
Any help would be greatly appreciated, and thank you.

Option Explicit
Dim objDialog, oFSO, intResult, pad, nbr, i, strpath

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "Text Files|*.txt|All Files|*.*"
objDialog.FilterIndex = 1
objDialog.InitialDir = "C:\"
intResult = objDialog.ShowOpen

If intResult <> 0 Then
MsgBox objDialog.FileName
End If

strpath = objDialog.FileName

nbr = InputBox ("Enter the number of Files to Create")
pad = "0"
'MsgBox objDialog.FileName, vbOK

Set oFSO = CreateObject("Scripting.FileSystemObject")

i = 1
While i < 10
oFSO.GetFile(strpath).Copy "c:\Test\strpath" & pad & i & ".txt"
i = i+1
Wend

Do while i =< CInt(nbr)
oFSO.GetFile(strpath).Copy "c:\Test\strpath" & i & ".txt"
i = i+1
Loop

WScript.Quit
 
"c:\Test\strpath" & i & ".txt"
This is hard coded ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top