ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,731
- Office Version
- 2007
- Platform
- Windows
Morning,
I have merged two codes together but the seocnd part of the code does not execute / run
I press my PRINT 1 INVOICE BUTTON on my worksheet.
The invoice is then printed.
I see the msgbox CLEAR INVOICE AFTER PRINTING.
I press the OK button but after the msgbox is closed then this is where the next part does not execute,see text in red.
Many thanks
[/COLOR]
I have merged two codes together but the seocnd part of the code does not execute / run
I press my PRINT 1 INVOICE BUTTON on my worksheet.
The invoice is then printed.
I see the msgbox CLEAR INVOICE AFTER PRINTING.
I press the OK button but after the msgbox is closed then this is where the next part does not execute,see text in red.
Many thanks
Code:
Private Sub Print_One_Invoice_Click()
If Range("N18") = "" Then
MsgBox ("PLEASE SELECT A PAYMENT TYPE "), vbCritical, "Payment Type Not Selected"
Else
ActiveWindow.SelectedSheets.PrintOut Copies:=1
MsgBox "CLEAR INVOICE AFTER PRINTING"
[COLOR=#ff0000] Dim strFileName As String[/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES\" & Range("N4").Value & ".pdf"[/COLOR]
[COLOR=#ff0000] If Dir(strFileName) <> vbNullString Then[/COLOR]
[COLOR=#ff0000] MsgBox "INVOICE " & Range("N4").Value & " WAS NOT SAVED AS IT ALLREADY EXISTS", vbCritical + vbOKOnly[/COLOR]
[COLOR=#ff0000] Exit Sub[/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] [/COLOR]
[COLOR=#ff0000] With ActiveSheet[/COLOR]
[COLOR=#ff0000] .PageSetup.PrintArea = "$G$3:$O$61"[/COLOR]
[COLOR=#ff0000] .ExportAsFixedFormat Type:=xlTypePDF, Filename:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False[/COLOR]
[COLOR=#ff0000] MsgBox "INVOICE " & Range("N4").Value & " WAS SAVED SUCCESSFULLY", vbInformation + vbOKOnly[/COLOR]
[COLOR=#ff0000] Range("G27:N36").ClearContents[/COLOR]
[COLOR=#ff0000] Range("G46:G48").ClearContents[/COLOR]
[COLOR=#ff0000] Range("G47:I51").ClearContents[/COLOR]
[COLOR=#ff0000] Range("N18").ClearContents[/COLOR]
[COLOR=#ff0000] Range("N4").Value = Range("N4").Value + 1[/COLOR]
[COLOR=#ff0000] Worksheets("INV2").Range("N4").Value = Range("N4").Value[/COLOR]
[COLOR=#ff0000] Range("G13").ClearContents[/COLOR]
[COLOR=#ff0000] Range("G13").Select[/COLOR]
[COLOR=#ff0000] ActiveWorkbook.Save[/COLOR]
[COLOR=#ff0000] End With[/COLOR]
[COLOR=#ff0000] End If[/COLOR]
[COLOR=#ff0000] End If[/COLOR]
[COLOR=#ff0000]End Sub
[/COLOR]