+ Reply to Thread
Results 1 to 5 of 5

Save Workbook

  1. #1
    Registered User
    Join Date
    10-08-2004
    Posts
    49

    Question Save Workbook

    Help, code for the following required

    I have a workbook called elephant. I want to run a macro that will save the elephant workbook as elephantOLD to a different drive

    elephant location C:\
    Save elephant to E:\ as elephantOLD read only selected

    elephant to stay open for further editing after macro has run.

    A bit like a backup file but with a name change and read only selected.

    Thanks

    solti

  2. #2
    Registered User
    Join Date
    01-19-2007
    Location
    Bangalore, India
    Posts
    66

    Re:

    Hi,
    Try this code. Copy it to some module in elephant. You should be able to do what you want.

    Dim strRealWB, strNewWB As String
    On Error GoTo test
    strRealWB = ActiveWorkbook.FullName
    ActiveWorkbook.SaveAs "E:\" & Mid(ActiveWorkbook.Name, 1, Len _(ActiveWorkbook.Name) - 4) & "old.xls", , , , True
    ActiveWorkbook.Save
    strNewWB = ActiveWorkbook.FullName
    Application.ScreenUpdating = False
    Workbooks.Open strRealWB
    Application.Workbooks(strNewWB).Close
    Application.ScreenUpdating = True
    test:
    Workbooks(1).Close True

    There should not be any other workbook opened while executing this macro.
    regards,
    Gajendra Gupta

  3. #3
    Registered User
    Join Date
    10-08-2004
    Posts
    49
    Gajendra thanks for the reply

    I get a compile error syntax error on line

    ActiveWorkbook.SaveAs "E:\" & Mid(ActiveWorkbook.Name, 1, Len _(ActiveWorkbook.Name) - 4) & "old.xls", , , , True

    Plus what do the four ,,,, True stand for

    solti

  4. #4
    Registered User
    Join Date
    10-08-2004
    Posts
    49
    Found the problem it was the line break
    Len _(ActiveWorkbook.Name)

    still would like to now what the four ,,,, True stand for

    solti

  5. #5
    Registered User
    Join Date
    01-19-2007
    Location
    Bangalore, India
    Posts
    66

    Re:

    Hi,

    You use it to make your workbook 'ReadOnly'.

    Regards,
    Gajendra Gupta

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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