Save invoice to PDF and dont print macro objects

KingCraig

New Member
Joined
May 26, 2015
Messages
6
Good afternoon,
I have modified an invoice template to make it my own and now I want to perfect it.

Following the podcasts my template now has an invoice number generator, saves invoice to separate file, posts to a register and then wipes out all of the data ready for the next one.

Two small problems:

1. I want to save to a PDF instead of an excel workbook. I have tried to change this to PDF but doesn't work for me.

Sub SaveWithNewName()
Dim NewFN As Variant
PostToRegister
' Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "C:\Invoice\JHInv" & Range("F3").Value & ".pdf"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
End Sub

2. The Macro icons print when I "print" the invoice.
I would like to make it a button at the bottom of the template something like done or record and then it will save a specified area of the workbook so the button doesn't show up on the invoice.

Thank you
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
1.) If you have Excel 2007 or Later.

Code:
[color=darkblue]Sub[/color] SaveWithNewName()
    
    PostToRegister
    
    ActiveSheet.ExportAsFixedFormat _
        Type:=xlTypePDF, _
        Filename:="C:\Invoice\JHInv" & Range("F3").Value & ".pdf", _
        Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, _
        IgnorePrintAreas:=False, _
        OpenAfterPublish:=[color=darkblue]False[/color]
        
    NextInvoice
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]

2.) You can define a Print Area. Is that what you want?
 
Upvote 0
AlphaFrog - U DA Man! Thank you so much.
I know some day I will understand what I am typing but until then...
Again, Thank You
 
Upvote 0
hello sir,
please i need your help i cant use the above code am trying to save the invoice only pdf format and this my code:
Sub PostToRegister()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Set ws1 = Worksheets("invoice")
Set ws2 = Worksheets("Register Invoice")

' figure out which row is the new row
NewRow = ws2.Cells(Rows.Count, 1).End(xlUp).Row + 1

' write the important values to register
ws2.Cells(NewRow, 1).Resize(1, 4).Value = Array(ws1.Range("E11"), ws1.Range("B8"), ws1.Range("E12"), Range("E36"))

End Sub




Sub NewInvoice()
Range("E12").Value = Range("E12").Value + 1
Range("A16:D35").ClearContents
Range("B8:B12").ClearContents
End Sub


Sub SaveInvWithNewName()
Dim NewFN As Variant
PostToRegister
' Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "C:\Users\Ali\Desktop\Invoice record\inv" & Range("E12").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NewInvoice
End Sub

please your support.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top