Export as both Excel Workbook and PDF

2nd_Vice

New Member
Joined
Dec 28, 2016
Messages
1
Hello everybody!

After several hours of code hunting (I'm very new to VBA coding in excel) I've decided that I'm just going to ask on these forums and hopefully make more headway this way. I've gotten my invoice numbers to update as well as clearing my cells (this is for an invoice document for my grandparents towing business). What I'm basically trying to do is assign a macro to a single button that will

1) Save her workbook as an excel workbook for any future corrections. I was hoping to make excel save it with her company name as well as the invoice number? I watched MrExcel on youtube (podcast 1505 I think it was or something like that) and couldn't get the code to work for me.

2) I was also hoping that a PDF could be generated at the same time?

After the first two actions are completed, I'm then thinking that the code that I currently have will increase her invoice number by 1 as well as clearing her bill to field and other fields that I have assigned.

I'm trying to make this as simple for her as possible but I figured I'd ask and see if this is possible?

This is also for Excel 2013 on Windows 10....didn't know if that is relevant or not. I've read on some forums that it does matter so I figured that I'd include that information as well.

If anyone has a previous forum post that would work for me to figure this out I'd appreciate that as well!

Thanks everyone!
 

Some videos you may like

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

HackSlash

Active Member
Joined
Nov 18, 2016
Messages
360
This is the basic idea of saving to PDF with a variable name:

Code:
<code>Dim strFilename     As String
Dim InvoiceNumber        As String

InvoiceNumber = "Put your Invoice number stuff in here"

'Change this to match what you want the file name to be:
strFilename = <code>"Company Name" & InvoiceNumber & Date</code>

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "C:\Users\Allen\Desktop\Projects\" & strFilename & ".pdf" _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False</code>

P.S. Everybody hates the tow company. It's basically grand theft auto. You should look in to more honest work.
 
Last edited:

Watch MrExcel Video

Forum statistics

Threads
1,122,518
Messages
5,596,621
Members
414,082
Latest member
sasmita

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
Top