Consulting

Results 1 to 4 of 4

Thread: Solved: Copy a file to the users desktop

  1. #1
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location

    Solved: Copy a file to the users desktop

    This is the last question for a while.

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

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

    [VBA]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[/VBA]

  2. #2
    VBAX Expert
    Joined
    Aug 2007
    Location
    Windermere, FL, a 'burb in the greater Orlando metro area.
    Posts
    567
    Location
    Simon Lloyd answered a question very similar to yours on Saturday; look at this msg:

    http://www.vbaexpress.com/forum/show...882#post143882

    Cheers!
    Ron
    Windermere, FL

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    [vba]

    With ActiveWorkbook

    .SaveAs CreateObject("WScript.Shell").SpecialFolders("DeskTop") & Application.PathSeparator & .Name
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  4. #4
    VBAX Regular
    Joined
    Apr 2008
    Posts
    97
    Location
    Thanks, got it now....

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •