+ Reply to Thread
Results 1 to 8 of 8

SaveAs "Cancel" Error

  1. #1
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    SaveAs "Cancel" Error

    Hi Everyone,

    I have the following code I cobbled together from a few other scripts I use often. It does everything I want it to do with one exception.

    Basic Function:
    1. Ask if user wants to save their daily and clear the template
    2. Pull name and date from cells C3 & J3 and format a specific way.
    3. Open SaveAs dialog with formatted name
    4. After user Saves clear content and date and save base template without 'overwrite' dialog.

    Here is the snag I've found:

    If they hit "Cancel" on step 3 instead of hitting save, the script continues with clearing the data etc.

    What I want to happen if they cancel at step 3, is for the sub to be exited so none of the data is lost until they are ready to try saving again.

    I attempted to add this code:

    Please Login or Register  to view this content.
    But all that happens is the file is saved as "FALSE" if the user hits Cancel.

    Is there a solution to this or do I just have to instruct users not to hit Cancel and hope for the best?

    I apologize in advance that I have to post an image of the code, everytime I hit post I'm getting a SQL Injection Block error from my county's web security.

    Full Code:
    Capture.JPG

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: SaveAs "Cancel" Error

    Your county monitors your web traffic? That sounds a bit odd. As an alternative you could simply attach your Excel file.

    After assigning MyFile, have code like this. GetSaveAsFileName will return FALSE if the user hits Cancel.

    Please Login or Register  to view this content.
    vbCancel is just a built-in constant with a value of 2. It tells you nothing about what happened earlier in your code.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: SaveAs "Cancel" Error

    Quote Originally Posted by liquidmettle View Post
    ... everytime I hit post I'm getting a SQL Injection Block error from my county's web security ...
    Save it in the text file (with ".txt" extension) and insert it as an attachment.

  4. #4
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: SaveAs "Cancel" Error

    Hi 6StringJazzer,

    I work for a county government entity, so apparently when certain code looks malicious the web security flags it. This is only the second time I've seen such a warning for all the times I've posted while at work, so something in my code made it think it was possibly malicious SQL code.

    Adding
    Please Login or Register  to view this content.
    Right before
    Please Login or Register  to view this content.
    Did the trick!

    Thank you so much for your very quick reply!

    Porucha,

    That will be my future approach if this happens again (and makes much more sense!).

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: SaveAs "Cancel" Error

    Glad to hear it worked.

    Quote Originally Posted by liquidmettle View Post
    I work for a county government entity, so apparently when certain code looks malicious the web security flags it. This is only the second time I've seen such a warning for all the times I've posted while at work, so something in my code made it think it was possibly malicious SQL code.
    Oh, I see, the county is your employer. I am surprised they check outgoing pages. Usually checks for SQL injection are done as a defensive means for incoming content. In fact the Excel Forum has a screen for that by a third party called Securi. (Unfortunately sometimes it is too aggressive and flags VBA code as being HTML injection.)

  6. #6
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: SaveAs "Cancel" Error

    Actually I just assumed it was on my end, it was a Securi prompt so maybe it was Excel Forum's security.

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: SaveAs "Cancel" Error

    Quote Originally Posted by liquidmettle View Post
    maybe it was Excel Forum's security.
    Bingo. It's very aggressive. You may find this set of workarounds helpful.

  8. #8
    Forum Contributor
    Join Date
    05-23-2013
    Location
    Ohio
    MS-Off Ver
    Excel 2013
    Posts
    259

    Re: SaveAs "Cancel" Error

    Will look into those, cheers!

+ 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. [SOLVED] run into 1004 error "method 'saveas' of object '_workbook' failed" when saving wb copy
    By tadaw in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-10-2017, 06:18 AM
  2. [SOLVED] UserForm with "Cancel" and "Proceed" buttons
    By kappa0815 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-06-2017, 07:31 AM
  3. Replies: 35
    Last Post: 01-13-2016, 02:16 AM
  4. [SOLVED] Code Clean-Up: Delete "False" worksheet created when "Cancel" is chosen in Input Box
    By Kenny Blackwell in forum Excel Programming / VBA / Macros
    Replies: 25
    Last Post: 08-31-2015, 10:00 AM
  5. SAVEAS problem, "Error 1004".
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2012, 08:09 AM
  6. SaveAs problem with "Cancel"
    By michaelbails in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-26-2010, 12:53 AM
  7. [SOLVED] "SaveAs" Generates error on shared drive
    By RWN in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-22-2005, 11:07 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