Results 1 to 6 of 6

Need a Macro to save a file

Threaded View

  1. #1
    Registered User
    Join Date
    08-15-2013
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2007
    Posts
    10

    Need a Macro to save a file

    Hey All,

    I am a novice to Macro's so please explain things as if i am 2 years old not 46

    I need to create a Macro that allows the User to manually select a workbook from the network.

    the Macro then needs to save that workbook with a different name in a different directory.

    I have written this but have been having trouble with runtime error 1004 "excel cannont access file "trying to save a copy of the workbook


    If anyone could either suggest a solution to my problem or provide alternate code to do the same thing, It would be greatly appriecated -have spent 5 hours or more trolling excel boards looking for an answer

    thanks
    Dean

    Dim fName As Variant
    Dim savefilename As Variant
    MsgBox "Please Select MicroJets New Price Book"
    fName = Application.GetOpenFilename(FileFilter:="Excel Files (*.XLSX), *.XLSX", Title:="Select File To Be Opened")
    If fName = False Then Exit Sub
    Set bk1 = Workbooks.Open(fName)
    savefilename = Mid(fName, InStrRev(fName, "\") + 1)
    MsgBox savefilename
    
    Dim MyDate
    MyDate = Date    ' MyDate contains the current system date.
    Dim MyTime
    MyTime = Time    ' Return current system time.
    Dim TestStr As String
    TestStr = Format(MyTime, "hh.mm.ss")
    Dim Test1Str As String
    Test1Str = Format(MyDate, "DD-MM-YYYY")
    
    Application.DisplayAlerts = False
    
    ActiveWorkbook.SaveCopyAs filename:="C:\Users\Public\Public Documents\Work-Macros\" & Test1Str & " " & TestStr & " " & savefilename
    
    Application.DisplayAlerts = True
    Last edited by Dean Staples; 08-30-2013 at 09:21 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Save as macro that specifies file type, file location and takes file name from three cells
    By ExcelFailure in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 06-13-2013, 10:09 PM
  2. [SOLVED] macro to save file to specific folder with file name from cell reference
    By mezza89 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-06-2013, 11:32 AM
  3. Replies: 5
    Last Post: 05-08-2013, 06:23 AM
  4. Macro to save sheet as CSV using a dynamic file name and file path
    By chris.tinta in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2013, 10:45 AM
  5. macro save file for current year and month with a file name SHReportddmmyy.xls
    By evwang in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-14-2011, 10:38 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1