ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,738
- Office Version
- 2007
- Platform
- Windows
Morning,
I have the following supplied code which i run after i have printed an invoice.
It saves a word invoice to the folder mentioned & informs me with a message box once done.
Could you advise a edit where it will only allow the save to go ahead if that invoice number does not exist.
I mean if there is an invoice number 100 already show msg box otherwise continue and save.
Just a back up so i dont overwrite an existing file.
Many thanks
I have the following supplied code which i run after i have printed an invoice.
It saves a word invoice to the folder mentioned & informs me with a message box once done.
Could you advise a edit where it will only allow the save to go ahead if that invoice number does not exist.
I mean if there is an invoice number 100 already show msg box otherwise continue and save.
Just a back up so i dont overwrite an existing file.
Code:
Private Sub Clear_Invoice_After_Printing_Click()
Dim objWord As New Word.Application
'Copy the range Which you want to paste in a New Word Document as a screenshot
Dim strFileName As String
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES\Invoice " & Range("N4").Value & " " & Format(Now, "dd-mm-yyyy") & ".doc"
Range("G3:O60").CopyPicture xlPrinter
With objWord
With .Documents.Add
.Parent.Selection.Paste
.SaveAs strFileName
.Close
End With
'.Visible = True
.Quit
End With
MsgBox strFileName, vbInformation, "Invoice Saved as Screenshot Word.doc"
Range("G13:I18").ClearContents
Range("N14:O18").ClearContents
Range("G27:N42").ClearContents
Range("G13:I13").ClearContents
Range("G49:I49").ClearContents
Range("G48:I48").ClearContents
Range("G47:I47").ClearContents
Range("G46:I46").ClearContents
Range("G45:I45").ClearContents
Range("N4").Value = Range("N4").Value + 1
Worksheets("INV 2").Range("N4").Value = Range("N4").Value
Range("G13").Select
ActiveWorkbook.Save
End Sub
Many thanks