+ Reply to Thread
Results 1 to 11 of 11

Thread: SaveAs Procedure wont complete unless Ended

  1. #1
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    SaveAs Procedure wont complete unless Ended

    I have a procedure which will open a template and save as with a particular naming convention. During testing it was working well with a test template.

    Now switched the template it is opening to the live one, it gets to the activeWorkbook.SaveAs code and sits on the timer I have tried waiting it out but noticed...

    If I end the procedure the save as actually completes.

    I've tried things like making sure calculations are turned off in the template and that the on exit macro checks are fine. I can't figure it out.

    Any help figuring out what the delay may be would be great, I need it to get pass this stage to complete the rest of the procedure.

    Cheers,

    Lisa
    Last edited by lisa_jd; 11-19-2010 at 05:00 AM.

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: SaveAs Procedure wont complete unless Ended

    We need to see the actual code and/or the workbook
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    Re: SaveAs Procedure wont complete unless Ended

    This is where it gets stuck. Unfortunately I can't put the workbook up. Will see if i can take some content out of the template and post that. i am thinking along the line of its something in the template or other set ups. Its not the code as works fine with a blank worksheet.

    Sub TimesheetDeploy2()
    'Written by Lisa Davidson, NQBP Commercial Contracts and Projects Coordinator
    
        'Save As
            Dim PathStr As String
            Dim SaveStr As String
            Dim NameStr As String
            Dim DateStr As String
            
            NameStr = "Timesheet_" & ActiveSheet.Range("D4").Value
            DateStr = Format(ActiveSheet.Range("D6").Value, "yymmdd")
            PathStr = "PathName"
            SaveStr = PathStr & NameStr & "_" & DateStr
            FileExtStr = ".xls"
            
            With ActiveWorkbook
                   .SaveAs SaveStr & FileExtStr
                   .Close SaveChanges:=False
                   On Error Resume Next
                   
            End With
        
        'Open Timesheet Again
            Workbooks.Open TimesheetPath & TimesheetName
        
        'Go Back to Employee Summary.xls
            Workbooks(EmpSum1).Activate
            ActiveCell.Offset(1, 0).Select
        
    End Sub

  4. #4
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    Re: SaveAs Procedure wont complete unless Ended

    is there something to force it to action?

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: SaveAs Procedure wont complete unless Ended

    If the code runs fine with a blank sheet, then we'd need to see the workbook I suspect.
    Is this code in the workbook that is active at the time (i.e. the one you are saving and closing?)

  6. #6
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    Re: SaveAs Procedure wont complete unless Ended

    I have figured out what it is but need to know how to overcome.

    In the template file, I have a before save procedure. If this is not in the template file i don't have the problem when I try to run the Save As procedure (which is in another file).

  7. #7
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: SaveAs Procedure wont complete unless Ended

    What's this

    PathStr = "PathName"
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: SaveAs Procedure wont complete unless Ended

    If you don't want the BeforeSave procedure to run, then use:
    Application.EnableEvents = False
    before the code that saves the file, then set it back to True afterwards.

  9. #9
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    Re: SaveAs Procedure wont complete unless Ended

    Thats were there is a long winded path name that I thought i'd do you the favour of not having to read.

    i have run a few more test the problem is the automated before save macro in the template. I changed the location of the to before close. It saves then obviously stops on the:

    .Close SaveChanges:=False

    I need the template to have this macros active is there another close code that would close that would overwrite the before close macro?

  10. #10
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: SaveAs Procedure wont complete unless Ended

    I think a workbook would help
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  11. #11
    Registered User
    Join Date
    05-27-2010
    Location
    Brisbane, Australia
    MS-Off Ver
    Excel 2003 (Work) 2007 (Home)
    Posts
    20

    Re: SaveAs Procedure wont complete unless Ended

    Oh thank you so much it works!!! Your are a star, this has been bugging me for the last few hours!

+ 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.2.0