+ Reply to Thread
Results 1 to 11 of 11

Save as works but crashed excel...

  1. #1
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Save as works but crashed excel...

    Hi,
    I have this code which renames the file and saves in a designated folder. However, although it saves the file, it crashed excel so i'm guessing i've gone wring somewhere. Can anyone help?

    Please Login or Register  to view this content.
    As well as this I would also like it to clear all sub's in the worksheet. Can this be done?

    Regards
    Jimmi
    Last edited by jimmisavage; 06-26-2019 at 06:51 AM.

  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: Save as works but crashed excel...

    why are you changing the directory? just code that in for your newFile. does that make sense?

  3. #3
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Save as works but crashed excel...

    Quote Originally Posted by dmcgov View Post
    why are you changing the directory? just code that in for your newFile. does that make sense?
    So you're saying something like this?

    Please Login or Register  to view this content.
    Okay, I have got that working. I wanted to edit it slightly because it's actually on a network drive. It works fine when the netwrok drive is allocated "S" but if someone else has it as "T" (for instance) then it's going to throw an error. I changed the location to "\\mynetworkdrive\example\example\example" but it doesn't want to find that. Am I using it right?
    Last edited by jimmisavage; 06-26-2019 at 09:41 AM.

  4. #4
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Save as works but crashed excel...

    Possibly because you're saving the file before saving the file??? Why not just save the file in a normal subroutine?
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Save as works but crashed excel...

    Quote Originally Posted by dangelor View Post
    Possibly because you're saving the file before saving the file??? Why not just save the file in a normal subroutine?
    Please Login or Register  to view this content.
    It's strange because both ways react the same. If I save it by using 'Save As' it saves fine. But if I just click 'Save' or the save icon then it crashes excel.
    Although it does save the file

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    MS365 V.2406
    Posts
    2,317

    Re: Save as works but crashed excel...

    It may be crashing because it goes into an infinite loop - saving a file in a 'beforesave' subroutine triggers the 'beforesave' sub which triggers the 'beforesave'....

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

    Re: Save as works but crashed excel...

    Please Login or Register  to view this content.
    make sure to add '\' to your filename so it becomes:

    Please Login or Register  to view this content.
    let me figure out code for path change

  8. #8
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Save as works but crashed excel...

    Quote Originally Posted by dangelor View Post
    It may be crashing because it goes into an infinite loop - saving a file in a 'beforesave' subroutine triggers the 'beforesave' sub which triggers the 'beforesave'....
    Okay, that makes sense.
    How would I work around that? It doesn't need to save before saving, it just needs to change the name and then save.

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

    Re: Save as works but crashed excel...

    so say you have two network drives, S: and T:

    will the ThisWorkbook reside in either S or T?

    or how will you differentiate between the two drives?

  10. #10
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Save as works but crashed excel...

    Quote Originally Posted by dmcgov View Post
    so say you have two network drives, S: and T:

    will the ThisWorkbook reside in either S or T?

    or how will you differentiate between the two drives?
    I'm talking about the same network drive. Only on my PC it might be mapped as S but on another it could be mapped as T.

  11. #11
    Forum Contributor
    Join Date
    10-30-2006
    MS-Off Ver
    O365
    Posts
    311

    Re: Save as works but crashed excel...

    Quote Originally Posted by dangelor View Post
    It may be crashing because it goes into an infinite loop - saving a file in a 'beforesave' subroutine triggers the 'beforesave' sub which triggers the 'beforesave'....
    Okay, I've worked around it by making it auto save when the file is opened. That way the original will always stay in tact and the new file is ready to go.

+ 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. Excel crashed by double-click
    By neu_stone in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-16-2019, 10:38 AM
  2. Recover Crashed Excel file. :( :( :(
    By meus in forum Excel General
    Replies: 2
    Last Post: 06-29-2015, 10:26 AM
  3. Any way to save VBA code so it works with older Excel revisions?
    By fugazi48 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-16-2006, 09:10 AM
  4. Replies: 3
    Last Post: 11-26-2005, 04:00 AM
  5. Excel Crashed Terribly
    By Kiran in forum Excel General
    Replies: 5
    Last Post: 08-16-2005, 02:05 PM
  6. [SOLVED] Excel workbook crashed
    By Edgar Thoemmes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-21-2005, 09:06 AM
  7. [SOLVED] adding before save so it works every time excel opens and with any workbook
    By Job in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-12-2005, 07:06 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