+ Reply to Thread
Results 1 to 12 of 12

sheet not saving in correct filepath, instead its saving it to My Documents

Hybrid View

  1. #1
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: sheet not saving in correct filepath, instead its saving it to My Documents

    What exactly do you want/not want in the new 'PO' workbook(s)?
    If posting code please use code tags, see here.

  2. #2
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: sheet not saving in correct filepath, instead its saving it to My Documents

    so i made a change to the code, it's failing on Workbooks("Purchase order-Template").Sheets("Formulas").Copy Before:=openworkbook.Sheets(1), gives me a run time error '91', object variable or with block variable not set

    Sub CreatePO()
        'copy sheet to new workbook
        Dim wb As Workbook
        
        abc = ActiveSheet.Name
        Sheets("formulas").Range("AB1") = Sheets(abc).Range("I39")
        
        Set wb = Workbooks.Add
        
        ThisWorkbook.ActiveSheet.Copy Before:=wb.Sheets(1)
        
        'save workbook as xlsm
        'wb.SaveAs ActiveSheet.Name, FileFormat:=52
        wb.SaveAs ThisWorkbook.Path & "\" & abc, FileFormat:=52
    
        Dim openworkbook
        Dim x1
        
        Dim FNametxt As String, FNamefrm As String, FileSelected As String, FileName As String
            With ThisWorkbook
            Let FNametxt = .Path & "\PO\code.txt"
            .VBProject.VBComponents("Module1").Export FNametxt
            Let FNamefrm = .Path & "\PO\form.frm"
            .VBProject.VBComponents("UserForm1").Export FNamefrm
            Let FNamecal = .Path & "\PO\calendar.frm"
            .VBProject.VBComponents("frmCalendar").Export FNamecal
            End With
    
        Workbooks.Open abc
    
        Sheets(abc).Activate
        ActiveWorkbook.VBProject.VBComponents.Import FNametxt
        ActiveWorkbook.VBProject.VBComponents.Import FNamefrm
        ActiveWorkbook.VBProject.VBComponents.Import FNamecal
        ActiveWorkbook.Save
        
        Set openworkbook = Workbooks.Open(abc)
         
        Application.ScreenUpdating = False
        
         'With Workbooks("Purchase order-Template")
            Workbooks("Purchase order-Template").Activate
            Workbooks("Purchase order-Template").Sheets("Formulas").Copy Before:=openworkbook.Sheets(1)
            Workbooks("Purchase order-Template").Sheets("Master").Copy Before:=openworkbook.Sheets(1)
            Workbooks("Purchase order-Template").Sheets("BigMaster").Copy Before:=openworkbook.Sheets(1)
            Workbooks("Purchase order-Template").Sheets("Estimating1").Copy Before:=openworkbook.Sheets(1)
            Workbooks("Purchase order-Template").Activate
        'End With
        
        'close purchase order-template, DONT SAVE
        Workbooks("Purchase Order-template.xlsm").Activate
            'Application.DisplayAlerts = False
            'ActiveWorkbook.Close
            'Application.DisplayAlerts = True
            'another way to close the file without seeing any prompts
        Workbooks("Purchase Order-template.xlsm").Close SaveChanges:=False
    
    End Sub
    thoughts?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA code not saving into FilePath
    By Keith Edgar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-27-2014, 08:14 AM
  2. [SOLVED] Macro to save to Network Drive is saving to My Documents
    By MooseAUH in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2014, 07:26 AM
  3. [SOLVED] Complex Parsing and Saving as Multiple Text Documents
    By johnph in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 06-29-2012, 04:13 PM
  4. [SOLVED] Word not saving documents correctly
    By J.wills in forum Word Programming / VBA / Macros
    Replies: 5
    Last Post: 03-27-2009, 06:08 AM
  5. saving documents with macros
    By shrek in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-10-2005, 06:20 PM
  6. Saving New Documents on a network Drive.
    By MaxZ in forum Excel General
    Replies: 1
    Last Post: 11-09-2005, 06:35 PM
  7. Saving to users My Documents
    By Rob Edwards in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-24-2005, 06:07 AM
  8. Open documents interfering with saving
    By mgasparel in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2005, 05:26 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