早上好。我遇到了一段过去对我来说效果很好的代码。
Private Sub Workbook_Open()
UserForm1.Show
End Sub
存储在用户窗体中
Private Sub CommandButton1_Click()
' Verify All Fields
Msg = "Have you entered all Fields?"
Title = "TONU"
Config = vbYesNo + vbQuestion
Ans = MsgBox(Msg, Config, Title)
If Ans = Yes Then GoTo nextstep:
If Ans = No Then Exit Sub
nextstep:
' Print Option
Msg1 = "Would you like to Print a hard copy?"
Title1 = "TONU"
Config1 = vbYesNo + vbQuestion
Ans1 = MsgBox(Msg1, Config1, Title1)
If Ans1 = Yes Then UserForm1.Print
If Ans1 = No Then Run Report
lastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row + 1
MsgBox lastRow
End Sub
用户窗体在我的其他项目中打印得很好,但是当在新项目中使用此代码时它不会打印?!?!想法?