Copying a file

nosferatu26

Registered User.
Local time
Today, 01:56
Joined
Jul 13, 2015
Messages
57
Hello,

All I am trying to do is copy a pdf from a shared network onto the users desktop and then open it.

after googling around, this is what I came up with:
Code:
 My.Computer.Network.DownloadFile(FilePath, "C:\Users\" & GetUserName & "\Desktop\FileName")
  
 Application.FollowHyperlink DesktopPath
unfortunately its giving me an error for the first line, saying "=" is expected. When I found this code online there wasn't any mention of this and I am unsure what to do. The second line works but only for opening a specified file; but what I want to do is copy it to their desktop first so they aren't opening the original one on the network.

If anyone can help me out I would greatly appreciate it.
 
Not familiar with the first. Check out FileCopy.
 
First: in VBA, when function parameters are put in parentheses [()], function result is expected to be assigned to a variable:
Code:
VarName = My.Computer.Network.DownloadFile(FilePath, "C:\Users\" & GetUserName & "\Desktop\FileName")
That is the expected '='.
Otherwise, you can remove the parentheses:
Code:
My.Computer.Network.DownloadFile FilePath, "C:\Users\" & GetUserName & "\Desktop\FileName"
Second: When you download the file, download it to specified location and filename, so that you can have it opened.
 

Users who are viewing this thread

Back
Top Bottom