copy file from server to desktop (1 Viewer)

WalterInOz

Registered User.
Local time
Tomorrow, 00:22
Joined
Apr 11, 2006
Messages
93
Hi all,

We have documents on the server that employees frequently need to fill in, such as time sheets, expenses, training records etc. People often have a copy of these docs on their own PCs for their convenience (no more looking for the docs on the server). A problem occurs when docs are updated and people submit outdated documents. I've tried to make access to the most recent docs easy by creating a little database with a link to the current doc behind buttons. This works OK. however, ... there are always people that forget to save a copy to their PC BEFORE enetering data into the forms despite a messagebox popping up telling them to do a -save as- first.
P
It would be better if when people click a button for a form the form gets copied to the desktop, then opens and they can start to enter data. I can't get it right though.

Could you please have a look at what I've got so far and comment on what might be the error?

Here's my code:


Code:
Private Sub cmdTimesheet_Click()
Dim StrMsg As String
Dim stDocName As String
Dim stLinkCriteria As String

Dim strFileName As String
Dim strFileNameCopy As String
Dim fileObj As Object
Dim stAppName As String

'strFileName is Name of the Form you want to copy, add the .doc/.xls or whatever extension
strFileName = "Timesheet.xls"
strFileNameCopy = Format$(Nz(Environ("username")) & strFileName)

'path to Form to copy
strFileName = "V:\HR_Administration\4_Staff_Forms\" & strFileName

'path to folder in which the New Form should be saved
strFileNameCopy = "C:\Documents and Settings\" & Format$(Nz(Environ("username")) & "\Desktop" & strFileNameCopy)
Set fileObj = CreateObject("scripting.filesystemobject")
fileObj.copyfile strFileName, strFileNameCopy, True

'Dim stAppName As String
stAppName = "C:\Documents and Settings\" & Format$(Nz(Environ("username")) & "\Desktop" & strFileNameCopy)
FollowHyperlink stAppName
DoCmd.Maximize
End sub


I get an error message on FollowHyperlink stAppName
That's not the only problem though as I don't see the file copied to my desktop either.

Thanks for your help.
 

unclejoe

Registered User.
Local time
Today, 22:22
Joined
Dec 27, 2004
Messages
190
Hi,

Try adding a backslash on & "\Desktop\".
 

WalterInOz

Registered User.
Local time
Tomorrow, 00:22
Joined
Apr 11, 2006
Messages
93
Tried your suggestion but unfortunately doesn't help UncleJoe
 

WalterInOz

Registered User.
Local time
Tomorrow, 00:22
Joined
Apr 11, 2006
Messages
93
I'd really appreciated if someone could put me on the right track with this one.

Thanks
 

unclejoe

Registered User.
Local time
Today, 22:22
Joined
Dec 27, 2004
Messages
190
Hi Walter,

Code:
'path to folder in which the New Form should be saved
strFileNameCopy = "C:\Documents and Settings\" & Format$(Nz(Environ("username")) & "\Desktop" & strFileNameCopy)
Set fileObj = CreateObject("scripting.filesystemobject")
fileObj.copyfile strFileName, strFileNameCopy, True

'Dim stAppName As String
stAppName = "C:\Documents and Settings\" & Format$(Nz(Environ("username")) & "\Desktop" & strFileNameCopy)
FollowHyperlink stAppName
DoCmd.Maximize

It appears that you have created a "double string concatenation".
Change it to something like...
Code:
'Dim stAppName As String
'stAppName = "C:\Documents and Settings\" & Format$(Nz(Environ("username")) & "\Desktop\" & strFileNameCopy)
'I remove this line above
stAppName = strFileNameCopy
'I added this line
Debug.Print stAppName
'add this line to check string and remove after checking
FollowHyperlink stAppName
DoCmd.Maximize

The above code work for me.

I'd really appreciated if someone could put me on the right track with this one.

Thanks
 

WalterInOz

Registered User.
Local time
Tomorrow, 00:22
Joined
Apr 11, 2006
Messages
93
Sorry for my late reply Unclejoe.
The modifaction you suggested works like a treat. Thank you so much for your help.
 

petehilljnr

Registered User.
Local time
Today, 07:22
Joined
Feb 13, 2007
Messages
192
A little off the subject, but you could always create Excel / Word templates (.xlt, .dot) and open them instead of copying the .xls, .doc files to the desktop.

It would then force a "save as" when the document was closed.

Pete.
 

Users who are viewing this thread

Top Bottom