thomaspatton
03-20-2008, 05:00 AM
Hopefully this'll be the last time I need help from ya'll for awhile. My workbooks almost done. Unformtunately, I'm running into an application problem now. Something in my VBA code is causing an App Error, not a Runtime error.
Here's my setup. User have a Right Click Menu that controls everything, including saving and exiting the Workbook. I don't give them access to the File menu or the X Button.
My Save code, placed in a module:
Public Sub AutoSv()
Dim OrgDir As String
Dim NwFy As String
Dim NwClsDt As String
If Worksheets("Class Information").Range("j1").Value = "" Then
MsgBox "You must first enter a Class Number in Cell J1 of the Class Information tab before saving.", vbOKOnly, "Stop!"
Exit Sub
Else
NwFy = "FY " & Right(Worksheets("Class Information").Range("j1").Value, 2)
NwClsDt = Worksheets("Class Information").Range("j1").Value
OrgDir = Left$(ActiveWorkbook.Path, 2) & "\amo\student information\" & NwFy & "\Class " & NwClsDt & "\"
ActiveWorkbook.SaveAs Filename:=OrgDir & "AMO-" & Worksheets("Class Information").Range("j1").Value & ".xls"
End If
End Sub
My closing code, attached to a UF Button:
Private Sub cmdExtWk_Click()
Dim ExStr As String
Dim ClsMsg As String
ufCommon.Hide
ExStr = MsgBox("Are you sure you want to exit the Student Workbook?", vbYesNo, "Closing Workbook...")
Select Case ExStr
Case Is = vbYes
swtchUpdateOff
With Application
.CellDragAndDrop = True
.OnKey "^{p}"
.OnKey "^{s}"
.OnKey "%{f11}"
.OnKey "^{c}"
.OnKey "^{v}"
.OnKey "^{a}"
.OnKey "^%{t}"
.CommandBars("Worksheet Menu Bar").Enabled = True
.CommandBars.ActiveMenuBar.Enabled = True
.DisplayFullScreen = False
.Worksheets("Security Warning").Visible = True
.Worksheets("Security Warning").Activate
swtchUpdateOn
End With
ClsMsg = MsgBox("Do you want to save changes?", vbYesNo, "Closing Workbook...")
Select Case ClsMsg
Case Is = vbYes
Application.Quit
ActiveWorkbook.Close True
Case Is = vbNo
Application.Quit
ActiveWorkbook.Close False
End Select
Case Is = vbNo
ufCommon.Show
End Select
End Sub
I've got a couple other procedures attached to the save portion that call it, but none of them relate to closing the book.
Sorry I can't give more info on this, but when the App errors out, I submit it to MS but don't get the "See how to fix this" link.
I uploaded my book in case neither of these snippets is the actual culprit.
*edit* See below
Here's my setup. User have a Right Click Menu that controls everything, including saving and exiting the Workbook. I don't give them access to the File menu or the X Button.
My Save code, placed in a module:
Public Sub AutoSv()
Dim OrgDir As String
Dim NwFy As String
Dim NwClsDt As String
If Worksheets("Class Information").Range("j1").Value = "" Then
MsgBox "You must first enter a Class Number in Cell J1 of the Class Information tab before saving.", vbOKOnly, "Stop!"
Exit Sub
Else
NwFy = "FY " & Right(Worksheets("Class Information").Range("j1").Value, 2)
NwClsDt = Worksheets("Class Information").Range("j1").Value
OrgDir = Left$(ActiveWorkbook.Path, 2) & "\amo\student information\" & NwFy & "\Class " & NwClsDt & "\"
ActiveWorkbook.SaveAs Filename:=OrgDir & "AMO-" & Worksheets("Class Information").Range("j1").Value & ".xls"
End If
End Sub
My closing code, attached to a UF Button:
Private Sub cmdExtWk_Click()
Dim ExStr As String
Dim ClsMsg As String
ufCommon.Hide
ExStr = MsgBox("Are you sure you want to exit the Student Workbook?", vbYesNo, "Closing Workbook...")
Select Case ExStr
Case Is = vbYes
swtchUpdateOff
With Application
.CellDragAndDrop = True
.OnKey "^{p}"
.OnKey "^{s}"
.OnKey "%{f11}"
.OnKey "^{c}"
.OnKey "^{v}"
.OnKey "^{a}"
.OnKey "^%{t}"
.CommandBars("Worksheet Menu Bar").Enabled = True
.CommandBars.ActiveMenuBar.Enabled = True
.DisplayFullScreen = False
.Worksheets("Security Warning").Visible = True
.Worksheets("Security Warning").Activate
swtchUpdateOn
End With
ClsMsg = MsgBox("Do you want to save changes?", vbYesNo, "Closing Workbook...")
Select Case ClsMsg
Case Is = vbYes
Application.Quit
ActiveWorkbook.Close True
Case Is = vbNo
Application.Quit
ActiveWorkbook.Close False
End Select
Case Is = vbNo
ufCommon.Show
End Select
End Sub
I've got a couple other procedures attached to the save portion that call it, but none of them relate to closing the book.
Sorry I can't give more info on this, but when the App errors out, I submit it to MS but don't get the "See how to fix this" link.
I uploaded my book in case neither of these snippets is the actual culprit.
*edit* See below