albertc30
Well-known Member
- Joined
- May 7, 2012
- Messages
- 1,091
- Office Version
- 2019
- Platform
- Windows
Hi all again.
Code bellow runs okay and executes all instructions.
However, there's still an error popping up.
What might be causing this?
Many thanks.
Code bellow runs okay and executes all instructions.
However, there's still an error popping up.
VBA Code:
Private Sub CBProfoInvoice_Click()
Beep
If MsgBox("You have selected a proforma invoice document." & vbNewLine & "This will generate your next invoice?", vbQuestion + vbYesNo, "Proforma to Invoice...") = vbNo Then
Exit Sub
End If
'save invoice pdf code below
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:= _
"D:\Software\Invoices\INV" & Range("F4").Text & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=False
Dim Data(1 To 5) As Variant
Dim DstRng As Range
Dim RngEnd As Range
Set DstRng = Worksheets("Invoices").Range("A1:E1")
Set RngEnd = DstRng.Parent.Cells(Rows.Count, DstRng.Column).End(xlUp)
Set DstRng = IIf(RngEnd.Row < DstRng.Row, DstRng, RngEnd.Offset(1, 0).Resize(1, 5))
With ActiveSheet
Data(1) = .Range("F4") 'Invoice number
Data(2) = .Range("C12") 'Invoice total
Data(3) = .Range("C14") 'Deposit
Data(4) = .Range("C16") 'Owed
Data(5) = .Range("F3") 'Proforma Number THIS IS NOT BEING COPIED ACROSS!!!
End With
DstRng = Data
CBGenDocument.Enabled = False
CBProfoInvoice.Enabled = False
Application.DisplayAlerts = False 'This is causing the issue...
'ActiveWindow.SelectedSheets.Visible = False
'ActiveWindow.SelectedSheets.Delete
ActiveSheet.Delete
Application.DisplayAlerts = True 'This is causing the issue...
Sheets("Create").Select
End Sub
What might be causing this?
Many thanks.