salvatore imparato
asked on
hot to assign to a icon a vbs script (500+500 pts)
Admit have a dir on server: \\myserver\mydir\
In this dir have five file excel:
test_8501.xls
test_8502.xls
test_8503.xls
test_8504.xls
test_8505.xls
how to make a vbs script file:
if the user press on vbs script icon, appear a form with a text box where the user can insert a code, similar 8501.
With a button on this form, start a code to copy a xls file from server dir with the last 4 charachter 8501 and paste the excel file in c:\mydir withouit popup yes/no for overwrite the existis file with the same name of current file
hope understnd me.
Tks to all
In this dir have five file excel:
test_8501.xls
test_8502.xls
test_8503.xls
test_8504.xls
test_8505.xls
how to make a vbs script file:
if the user press on vbs script icon, appear a form with a text box where the user can insert a code, similar 8501.
With a button on this form, start a code to copy a xls file from server dir with the last 4 charachter 8501 and paste the excel file in c:\mydir withouit popup yes/no for overwrite the existis file with the same name of current file
hope understnd me.
Tks to all
This version will allow a loop if an invalid code is entered...
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
CopyFile()
Set objFSO = Nothing
wscript.quit
Sub CopyFile()
strResp = InputBox ("Enter the code number","Input needed", "8501")
If objFSO.FileExists ("\\myserver\mydir\test_" & strResp & ".xls") Then
objFSO.CopyFile "\\myserver\mydir\test_" & strResp & ".xls", "C:\mydir\", True
Else
Msgbox "Sorry, that file does not exist. Please try again...", vbOkOnly, "Invalid File Code"
CopyFile()
End If
End Sub
ASKER
Hi sirbounty...
Yuo have understand perfect my Napolitan/English (i'm live in Napoli:-) the code work very well:
But when i click on cancel button the code go in loop and reapper the form....(?!)
Yuo have understand perfect my Napolitan/English (i'm live in Napoli:-) the code work very well:
But when i click on cancel button the code go in loop and reapper the form....(?!)
ASKER
... or when i click on "X" on the form
ASKER
... or when i click ctrl pause on the form
I understand...try this:
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
CopyFile()
Set objFSO = Nothing
wscript.quit
Sub CopyFile()
strResp = InputBox ("Enter the code number","Input needed", "8501")
If objFSO.FileExists ("\\myserver\mydir\test_" & strResp & ".xls") Then
objFSO.CopyFile "\\myserver\mydir\test_" & strResp & ".xls", "C:\mydir\", True
Else
strResult = Msgbox "Sorry, that file does not exist. Please try again...", vbRetryCancel, "Invalid File Code"
If strResult = vbCancel Then Exit Sub
CopyFile()
End If
End Sub
ASKER
Hi sirbounty...
with new version have the error in img attached...
To be sure attach here a your tersted version, tks.
Pizza for you!
with new version have the error in img attached...
To be sure attach here a your tersted version, tks.
Pizza for you!
ASKER
sorry...
doc1.doc
doc1.doc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WORK NOW!
But instead to use the standard input type tetxbox code, is possible to show a good and elegant form?
But instead to use the standard input type tetxbox code, is possible to show a good and elegant form?
No, that's the limitations of using plain vbscript...sorry...
Open in new window