PDA

View Full Version : Solved: Copy a file to the users desktop



slang
05-19-2008, 07:50 AM
This is the last question for a while.

How would I copy a file from c:\bdm to the users desktop?:banghead:
Thanks again, it's almost over....: pray2:

This is the mess I have now but I don't know how to reference the users desktop.

Sub Macro1()
Dim password As String
Application.DisplayAlerts = False
password = InputBox("Enter Training Password")
If password = "g" Then
Application.ScreenUpdating = False
ChDir "C:\BDR"
Workbooks.Open Filename:="C:\BDR\profiler 1.0.xls", UpdateLinks:=3
ChDir "C:\Documents and Settings\sclan\Desktop"
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\sclan\Desktop\profiler 1.0.xls", FileFormat:= _
xlNormal, password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
ActiveWindow.Close
Else
MsgBox "Invaid Password"
ActiveWorkbook.Close
End If
End Sub

RonMcK
05-19-2008, 08:01 AM
Simon Lloyd answered a question very similar to yours on Saturday; look at this msg:

http://www.vbaexpress.com/forum/showthread.php?p=143882#post143882

Cheers!

Bob Phillips
05-19-2008, 08:09 AM
With ActiveWorkbook

.SaveAs CreateObject("WScript.Shell").SpecialFolders("DeskTop") & Application.PathSeparator & .Name
End With

slang
05-19-2008, 09:23 AM
Thanks, got it now....

FileCopy "c:\Bdr\profiler 1.0.xls", "C:\Documents and Settings\" & Environ("username") & _
"\Desktop\" & "profiler 1.0.xls"