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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Desktop Icons with VB Script 2

Status
Not open for further replies.

willydude

Programmer
Oct 24, 2006
123
US
I am trying to add some desktop icons for a WIN98 PC. Each of these would be used to copy an individual file to a network folder, where I could then access the file from a different PC. I have tried the code below but keep getting an error message with the following info:

Error message:
Code:
Line: 4
Char: 15
Error: Syntax Error
Code: 800A03EA
Source: Microsoft VBScript Compilation Error

The error seems to be related to “handler”. I have similar code that works with Excel, but I am wanting the desktop icons instead. As it is pretty obvious, I am not familiar with VBScipt.

Here is my code:
Code:
Sub SendJobBreakdownFileToClientPayrollDropFolder
Application.DisplayAlerts = False
Dim SourceFile, DestinationFile
On Error GoTo handler
SourceFile = "G:\WIM\JobBrkdn.dat"
DestinationFile = "R:\ClientPayrollDropFolder\JobBrkdn.dat"
FileCopy SourceFile, DestinationFile

REM Exit Sub  ‘<< --Out of place also?
handler: MsgBox "Did not send properly."
Wscript.Echo "Sent"
End sub

Any help and/or fixits would be appreciated.

Thanks,

Bill
 
[tt]Sub SendJobBreakdownFileToClientPayrollDropFolder
Application.DisplayAlerts = False [blue]'Application? you probably need some more exact reference for vbs[/blue]
Dim SourceFile, DestinationFile
On Error [red]Resume Next[/red]
SourceFile = "G:\WIM\JobBrkdn.dat"
DestinationFile = "R:\ClientPayrollDropFolder\JobBrkdn.dat"
FileCopy SourceFile, DestinationFile [blue]'FileCopy : what is it[/blue]
[red]'[/red]REM Exit Sub ‘<< --Out of place also?
[red]'[/red]handler: MsgBox "Did not send properly."
[blue]if err.number<>0 then
MsgBox "Did not send properly."
else
Msgbox "Sent" 'either consistently wscript.echo or msgbox
end if[/blue]
End sub
[/tt]
 
PHV,

I went to the link you suggested. I got the code to work, kind of. The following sends the file, but the file has no data in it after being copied over to the destination. The file is there, just nothing in it. Before running the code below, I am able to open and edit the file through DOS, thus verifying that data is there. After doing so, I save it with the info intact. I’ve been manually dragging and dropping the file to this point.

Note that it is a .DAT file that I need to open and process in Excel, which I can do with VBA.

Code:
Dim Fso, FromWimPC
'FromWimPC is the source

Set Fso = CreateObject("Scripting.FileSystemObject")
Set FromWimPC = Fso.CreateTextFile("G:\WIM\JobBrkdn.dat", True)
Set FromWimPC = Fso.GetFile("G:\WIM\JobBrkdn.dat")
FromWimPC.Copy ("R:\ClientJobBreakdownWeekly\")
Thanks,

Bill
 
[tt]Set Fso = CreateObject("Scripting.FileSystemObject")
[green]'create means create anew, with true it even overwrites existing[/green]
[red]'[/red]Set FromWimPC = Fso.CreateTextFile("G:\WIM\JobBrkdn.dat", True)
Set FromWimPC = Fso.GetFile("G:\WIM\JobBrkdn.dat")
FromWimPC.Copy ("R:\ClientJobBreakdownWeekly\")
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top