+ Reply to Thread
Results 1 to 3 of 3

save in directory

  1. #1
    rlm
    Guest

    save in directory

    I am using the following code in the "before save" declaration in the
    workbook code. It works great except for one problem. It doesn't save the
    workbook in the directory I want it to. How do I get it to save in a certain
    directory/folder?

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Application.EnableEvents = False
    Cancel = True
    ThisWorkbook.SaveAs Worksheets("DEVIATION REPORT").Range("AM49").Value
    Application.EnableEvents = True

    End Sub

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Include the path


    ThisWorkbook.SaveAs "c:\test " & Worksheets("DEVIATION REPORT").Range("AM49").Value

  3. #3
    AA2e72E
    Guest

    RE: save in directory

    Specify the fully qualified path name:

    e.g to save Worksheets("DEVIATION REPORT").Range("AM49").Value

    to the default path

    application.defaultfilepath & "\" & Worksheets("DEVIATION
    REPORT").Range("AM49").Value

    to save to "c:\xx"

    "c:\xx" & "\" & Worksheets("DEVIATION REPORT").Range("AM49").Value

    The path must exists or it will fail.

    "rlm" wrote:

    > I am using the following code in the "before save" declaration in the
    > workbook code. It works great except for one problem. It doesn't save the
    > workbook in the directory I want it to. How do I get it to save in a certain
    > directory/folder?
    >
    > Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    > Application.EnableEvents = False
    > Cancel = True
    > ThisWorkbook.SaveAs Worksheets("DEVIATION REPORT").Range("AM49").Value
    > Application.EnableEvents = True
    >
    > End Sub


+ 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