Saving individual tabs as PDF with set naming convention

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have a workbook which has 16 tabs in it (and potentially more) which are quotes for indivdual clients.

What i want to do is have a macro which saves each tab as a pdf under the naming convention "Quote" Then the tab name, then cell D2, then cell D4. This would need to be saved in a specified folder on my D drive.

I have checked on this forum and found several pieces of code that relate to naming arrays but is there any way where it would just print/pdf all tabs and apply the above without having to name each one?

thanks in advance
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Code:
Sub stroffso()
  Const sPath       As String = "D:/somePath/Quote"
  Dim wks           As Worksheet

  For Each wks In Worksheets
    With wks
      .ExportAsFixedFormat _
          Type:=xlTypePDF, _
          Filename:=sPath & .Range("D2").Value & Range("D4").Value
    End With
  Next wks
End Sub
 
Upvote 0
Thanks for that. Thr first time I ran this it worked fine however ever since it kee[ps returning a run time error '1004'? I thought it might have been cause I had too many tabs in the doc but tried it with just 5 tabs and it still didnt work? Any ideas?

Code:
Sub stroffso()
  Const sPath       As String = "D:/somePath/Quote"
  Dim wks           As Worksheet

  For Each wks In Worksheets
    With wks
      .ExportAsFixedFormat _
          Type:=xlTypePDF, _
          Filename:=sPath & .Range("D2").Value & Range("D4").Value
    End With
  Next wks
End Sub
 
Upvote 0
Ok so i took the 2nd cekk Rabge Value off and it appeared to work. I think I know what the issue is now, the 2nd cell range was a date and had / / in it so i presume this is where the error has come from. thanks for the solution.
Thanks for that. Thr first time I ran this it worked fine however ever since it kee[ps returning a run time error '1004'? I thought it might have been cause I had too many tabs in the doc but tried it with just 5 tabs and it still didnt work? Any ideas?
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,821
Members
449,049
Latest member
cybersurfer5000

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