+ Reply to Thread
Results 1 to 5 of 5

save as problem

  1. #1
    Registered User
    Join Date
    06-07-2014
    Location
    New Zealand
    MS-Off Ver
    excel 2019
    Posts
    4

    Question save as problem

    Hi Guys

    Can any one help with this problem please.

    Sample code:-

    Please Login or Register  to view this content.
    This simple macro works the first time you save the file then the next time you save it you are presented with a "a file named **** already exists, do you want to replace it. yes/no/cancel.

    The problem is that if you press either "no" or "cancel" rather than "yes", a VB 400 error comes up.

    Question.

    Can i put some additional code in that prevents this VB 400 error comming up.

    Thanks in advance for any help.

    Regards

    Keith
    Last edited by AliGW; 05-15-2022 at 02:59 AM. Reason: Code tags added.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: save as problem

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. As this is your firts post here, I have done it for you this time.)

    Administrative Note:

    Members will tailor the solutions they offer to the version (NOT release number) of Office (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your version is for Mac, please also state this. Thanks.

    Administrative Note:

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Spammer
    Join Date
    10-23-2012
    Location
    Adelaide, Australia
    MS-Off Ver
    Excel 2003, Office 365
    Posts
    1,237

    Re: save as problem

    try this as a simple solution;
    Please Login or Register  to view this content.
    Last edited by Croweater; 05-15-2022 at 03:10 AM.

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: save as problem

    You could capture the error and perform a specific action if one occurs.
    i.e. the below version of your code will show a different message box if No or Cancell are selected.

    Please Login or Register  to view this content.
    BSB

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi, try this !


    A beginner level VBA demonstration without the need to trap any error :

    PHP Code: 
    Sub Demo1()
        
    Dim Bill$
        
    Bill "F:\quote\" & [quote!F2].Text
        If Dir(Bill) > "" Then If MsgBox("
    File " & Bill & " already exists Cancel ?", 4, "Control") = 6 Then Exit Sub Else Kill Bill
        ThisWorkbook.SaveAs Bill
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

+ 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. Save Problem
    By zrs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2019, 10:58 AM
  2. Save as PDF problem
    By thammondwis in forum Excel General
    Replies: 6
    Last Post: 04-15-2019, 11:25 AM
  3. before save problem
    By tmill29 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-21-2014, 07:06 PM
  4. Save As problem
    By Bob@Sun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-30-2010, 05:57 AM
  5. Problem with save xls into csv
    By mario99ukdw in forum Excel General
    Replies: 0
    Last Post: 10-29-2008, 02:53 AM
  6. Save as problem with Save In drop down box
    By Doug in forum Excel General
    Replies: 3
    Last Post: 03-16-2006, 10:50 AM
  7. save problem
    By Anthony in forum Excel General
    Replies: 3
    Last Post: 03-14-2005, 03:06 PM

Tags for this Thread

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