Link to home
Start Free TrialLog in
Avatar of brothertruffle880
brothertruffle880Flag for United States of America

asked on

VBA Script to save a workbook on the desktop or My Documents

Here's a VBA script that opens a workbook and then saves it to the desktop.  I have no idea what I did wrong.
Question 2:  does my procedure location matter? (i.e. Should this be in location 1, 2, or 3?) (See graphic below).

Option Explicit

Sub add_worksheet()

Dim TargetWorkbook As String
Dim DTAddress As Object
       
Dim wb As Workbook
    TargetWorkbook = "C:\summary.xlsx"
   
    Set wb = Workbooks.Open(TargetWorkbook)
   
    DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator

    wb.SaveAs (DTAddress & "summary.xlsx")

       
 End Sub

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Shanan212
Shanan212
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial