Automate saving a blank pdf from a list of names in a cell

IslandofBDA

New Member
Joined
Jun 15, 2024
Messages
6
Office Version
  1. 365
Platform
  1. Windows
  2. Web
for example
here is a sample list

SOA_FM_001
SOA_FM_002
SOA_FM_003
SOA_FM_004
SOA_FM_005
SOA_FM_006
SOA_FM_007
SOA_FM_008
SOA_FM_009
SOA_FM_010
SOA_FM_011
SOA_FM_012
SOA_FM_013
SOA_FM_014
SOA_FM_015
SOA_FM_016
SOA_FM_017
SOA_FM_018
SOA_FM_019
SOA_FM_020
SOA_FM_021
SOA_FM_022
SOA_FM_023
SOA_FM_024
SOA_FM_025


i would to save pdf file that is named with each label
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Code:
Sub Maybe_So()
Dim i As Long, PdfArr
PdfArr = Sheets("Sheet3").Cells(1).CurrentRegion
Sheets("Sheet1").PageSetup.PrintArea = "A1:I42"    '<---- ActiveSheet and also empty sheet
    For i = LBound(PdfArr) To UBound(PdfArr)
        ActiveSheet.ExportAsFixedFormat xlTypePDF, ThisWorkbook.Path & "\" & PdfArr(i, 1) & ".pdf"
    Next i
End Sub

Sheet3 cells A1 on down has the list of names.
Sheet1 is the ActiveSheet as well as an empty sheet
 
Upvote 0
BTW, if your numbering of file names is with consecutive values as you showed in Post #1, you don't need to have the names in another sheet.
Change "SOA_FM_" in below code to anything you want as file name.
Code:
Sub Maybe_So_2()
Dim i As Long
With Sheets("Sheet1")    '<---- or any sheet without data in the below mentioned (A1:I42) print range
    .PageSetup.PrintArea = "A1:I42"    '<---- or change to any empty area
        For i = 1 To 25    '<---- Change the 25 to any number < 1000 for amount of files to be saved
            .ExportAsFixedFormat xlTypePDF, ThisWorkbook.Path & "\" & "SOA_FM_" & Format(i, "000") & ".pdf"
        Next i
End With
End Sub
 
Upvote 0
Hello

thanks for the help

but this is the error ".ExportAsFixedFormat xlTypePDF, ThisWorkbook.Path & "\" & "SOA_FM_" & Format(i, "000") & ".pdf"
 
Upvote 0
Note that if you have not saved the file containing this VBA code anywhere yet, "ThisWorkbook.Path" would be empty/blank.
Have you decided where you want to save these files?
 
Upvote 0
Re: yes !
Does that mean Joe4 got you on the right track or that's where you want to save it.
The easiest would be to save the workbook in the same folder (C:\Users\ddb\Downloads\test enviroment) and then run the macro.
If that is not feasible, let us know and we'll give you the right line for that.
 
Upvote 0
OK ! Perfect it works!

but now I want to name the cell with what ever name is in each cell

", ThisWorkbook.Path & "\" & "SOA_FM_" & Format(i, "000") & ".pdf"

this labels each pdf "SOA_FM"

I want the name of the pdf to be the same name in each cell ie days of the week etc or student in a class room [ from 1 to .. let say 50 ]

cheers
 
Upvote 0
If the values are in Column A, try
Code:
", ThisWorkbook.Path & "\" & Cells(i, 1).Value & Format(i, "000") & ".pdf"
 
Upvote 0
Help!

ok! I have 2 issues

1. the pdfs are not blank . the pdf has the list of the values in the cell.
2. each pdf is formatted with addidtional number list

please advise
 
Upvote 0

Forum statistics

Threads
1,221,595
Messages
6,160,701
Members
451,665
Latest member
PierreF

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