Excel 2013,32和64位,Windows 7。
Excel工作表“AuditProgram”(NOT WORKBOOK)在运行“页面设置”和“打印预览”对话框时崩溃。如果我运行这些对话框,在此工作表上,它可以正常工作。但是当我去运行一个提取表单的宏时,它会崩溃。如果我从不打开两个对话框,宏工作正常。运行宏然后打印两个打印对话框后,文件也会在保存时崩溃。
对话框如何破坏工作表?
如果我隐藏行,它永远不会在宏上崩溃或保存。如果我将宏添加到快速访问工具栏并从那里单击它,它会在第二轮崩溃。如果我从“宏”菜单运行宏,它会在第8轮崩溃。它崩溃得少得多。所有其他工作表工作正常,即使我在这些工作表上运行对话框或宏,也不会崩溃。但我回到AuditProgram工作表,它在宏上崩溃了吗?这对我没有任何意义。有一些与内存泄漏,打印预览/页面设置以及Excel查看此特定工作表的方式有关。
注意:当它在宏上崩溃时,会立即崩溃。我甚至没有看到MMDia的形式出现。因此它在崩溃之前只运行4行代码。这太奇怪了!
注意:在表单MMDia上选择选项C ... MMOpt_V =“C”
注意:在表单PrtDia上单击选项PrtAPBtn ...范围(“PrtOpt”)= AP
宏:
Sub MainMenu()
Application.Run "MM"
End Sub
Private Sub MM()
Dim MMOpt_V As String
Dim Prt_V As String
Range("MMSel").ClearContents
Range("MMOpt").ClearContents
MMDia.Show
MMOpt_V = Range("MMOpt").Value
Range("MMSel").ClearContents
Range("MMOpt").ClearContents
If MMOpt_V = "A" Then
Application.Run "Headings"
End If
If MMOpt_V = "B" Then
Application.Run "AdPrgHide"
Application.Run "CklstHide"
End If
If MMOpt_V = "C" Then
PrtDia.Show
Prt_V = Range("PrtOpt").Value
Range("PrtOpt").ClearContents
If Prt_V = "Ques" Then
Application.Run "PrtQues"
ElseIf Prt_V = "AP" Then
Application.Run "PrtAP"
ElseIf Prt_V = "Cklst" Then
Application.Run "PrtCklst"
Else
End
End If
End If
If MMOpt_V = "D" Then
Application.Run "SUMacLib.xlsm!Templates"
End If
End Sub
Private Sub PrtAP()
Application.Goto reference:="Ques1"
Application.Goto reference:="AuditProgram!R1C1"
Application.Goto reference:="APLineRef1"
Application.ScreenUpdating = False
ActiveCell.Offset(6, 0).Select
CHDR = Worksheets("Headings").Range("APCHdr").Value
WkshtNM = Worksheets("Headings").Range("APWkshtNm").Value
CFTR = Worksheets("Headings").Range("TxTypName").Value
With ThisWorkbook.Worksheets("AuditProgram").PageSetup
.PrintTitleColumns = ""
.PrintTitleRows = "APPrtRow"
.CenterHeader = "&""Arial,Bold""&12" & CHDR & Chr(10) & WkshtNM & ""
.LeftHeader = ""
.RightHeader = "&""Arial,Normal""&10" & "Page &P of &N"
.CenterFooter = "&""Arial,Normal""&10" & CFTR
.PrintArea = "PrtRangeAP"
.Zoom = 85
End With
Application.Run "SUMacLib.xlsm!Prt_Port"
End Sub
Private Sub Prt_Port()
With Worksheets("AuditProgram").PageSetup
.TopMargin = Application.InchesToPoints(1.75)
.BottomMargin = Application.InchesToPoints(0.75)
.HeaderMargin = Application.InchesToPoints(0.75)
.Orientation = xlPortrait
End With
Application.Run "SUMacLib.xlsm!Prt_Doc"
End Sub
Private Sub Prt_Doc()
With Worksheets("AuditProgram").PageSetup
.ScaleWithDocHeaderFooter = False
.AlignMarginsHeaderFooter = True
.LeftFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.FooterMargin = Application.InchesToPoints(0.25)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.CenterHorizontally = True
.CenterVertically = False
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlOverThenDown
.BlackAndWhite = False
End With
Application.ScreenUpdating = True
Application.Goto reference:="APLineRef1"
Application.Dialogs(xlDialogPageSetup).Show
Application.Dialogs(xlDialogPrintPreview).Show
End Sub
表格MMDia:
Private Sub MMCancelBtn_Click()
Range("MMSel").ClearContents
Range("MMOpt").ClearContents
Unload Me
End Sub
Private Sub MMLst_Change()
Application.EnableEvents = False
Range("MMSel").Value = MMLst.Text
Application.EnableEvents = True
End Sub
Private Sub MMLst_Click()
Range("MMSel").Value = MMLst.Text
End Sub
Private Sub MMOkBtn_Click()
Range("MMOpt").FormulaR1C1 = "=left(MMSel,1)"
Unload Me
End Sub
表格PrtDia:
Private Sub PrtAPBtn_Click()
Range("PrtOpt").Value = "AP"
Unload Me
End Sub
Private Sub PrtCancelBtn_Click()
Range("PrtOpt").Value = "Stop"
Unload Me
End Sub
Private Sub PrtCklstBtn_Click()
Range("PrtOpt").Value = "Cklst"
Unload Me
End Sub
Private Sub PrtQuesBtn_Click()
Range("PrtOpt").Value = "Ques"
Unload Me
End Sub