Results 1 to 3 of 3

VBA Error Message Appearing if form not saved

Threaded View

  1. #1
    Registered User
    Join Date
    10-18-2012
    Location
    Jackson, MI
    MS-Off Ver
    Excel 2010
    Posts
    8

    VBA Error Message Appearing if form not saved

    I have created a form to save daily inspections using VBA and a Form Control Button (Save Form) based on the entry of a part# and date in two adjacent cells. The operator enters Part# in Cell B1 and Date in Cell B2 and selects the "Save Form" control button to unlock additional cells and start data entry.

    If a duplicate form is attempted to be created/saved, the error message “A File Name \\xxx.xlsm already exists in this location. Do you want to replace it?” appears as expected.

    When the user selects “No”, another Microsoft Visual Basic Message Box immediately appears indicating a Run Time has error has occurred because the form was not saved. The Message box requires the user to select “Debug, End or Help”

    Is there any method to stop the MS VBA error message box from appearing after the user selects “No” upon receiving the initial error method?

    Here is the code I am currently using to save the form:

    Sub SaveWithVariableFromCell()
           Dim SaveName As String
           SaveName = ActiveSheet.Range("J2").Text
           ActiveWorkbook.SaveAs Filename:="\\XXX\XXX\Completed Inspection Forms\" & _
               SaveName & ".xlsm"
           ActiveSheet.Protect DrawingObjects:=False, Contents:=False, Scenarios:=False
           Range("C11:L130").Select
           Selection.Locked = False
           Selection.FormulaHidden = False
           ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
           ActiveWorkbook.Save
    End Sub
    Last edited by Cutter; 10-18-2012 at 05:00 PM. Reason: Added code tags

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.6.0 RC 1