manekankit
Board Regular
- Joined
- Feb 1, 2019
- Messages
- 72
- Office Version
- 365
- Platform
- Windows
[FONT="]Hi,[/FONT]
[FONT="]Need help to create macro to export certain selected sheets as separate pdf files.[/FONT]
[FONT="]Steps are:[/FONT]
[FONT="]1. An excel file is open[/FONT]
[FONT="]2. It contains several sheets[/FONT]
[FONT="]3. It also contains a sheet named "Index"[/FONT]
[FONT="]4. Column A of the sheet "Index" contains name of some of the sheets form the same file.[/FONT]
[FONT="]5. Need to create macro that will export each of the sheets that are mention in range A1, A2 and so on in the sheet "Index"[/FONT]
[FONT="]5. Each pdf file should be saved at a specific location (at ruta4, refer code given below)[/FONT]
[FONT="]6. Each pdf file should be named like (yyyy-mmm-dd) and (sheet name)[/FONT]
[FONT="]I am using below code to create directory. Need help to create macro to select sheets and save these sheets as separate pdf files.
[/FONT]
[FONT="]Sub ExportPdf()
[/FONT]
[FONT="]Dim wb As Workbook[/FONT]
[FONT="]Set wb = ThisWorkbook[/FONT]
[FONT="]Dim ruta As String, ruta2 As String, ruta3 As String, ruta4 As String, nFile As String[/FONT]
[FONT="]nFile = Format(Date, "dd-mmm-yyyy")[/FONT]
[FONT="]ruta = wb.Path & ""[/FONT]
[FONT="]ruta2 = ruta & "export"[/FONT]
[FONT="]If Dir(ruta2, vbDirectory) = Empty Then[/FONT]
[FONT="]MkDir ruta2[/FONT]
[FONT="]End If[/FONT]
[FONT="]ruta3 = ruta2 & "PDF"[/FONT]
[FONT="]If Dir(ruta3, vbDirectory) = Empty Then[/FONT]
[FONT="]MkDir ruta3[/FONT]
[FONT="]End If[/FONT]
[FONT="]ruta4 = ruta3 & nFile & ""[/FONT]
[FONT="]If Dir(ruta4, vbDirectory) = Empty Then[/FONT]
[FONT="]MkDir ruta4[/FONT]
[FONT="]End If[/FONT]
[FONT="]<<<<Macro to create pdf as above steps and save it to ruta4 location>>>>>
[/FONT]
[FONT="]End Sub[/FONT]
[FONT="]Need help to create macro to export certain selected sheets as separate pdf files.[/FONT]
[FONT="]Steps are:[/FONT]
[FONT="]1. An excel file is open[/FONT]
[FONT="]2. It contains several sheets[/FONT]
[FONT="]3. It also contains a sheet named "Index"[/FONT]
[FONT="]4. Column A of the sheet "Index" contains name of some of the sheets form the same file.[/FONT]
[FONT="]5. Need to create macro that will export each of the sheets that are mention in range A1, A2 and so on in the sheet "Index"[/FONT]
[FONT="]5. Each pdf file should be saved at a specific location (at ruta4, refer code given below)[/FONT]
[FONT="]6. Each pdf file should be named like (yyyy-mmm-dd) and (sheet name)[/FONT]
[FONT="]I am using below code to create directory. Need help to create macro to select sheets and save these sheets as separate pdf files.
[/FONT]
[FONT="]Sub ExportPdf()
[/FONT]
[FONT="]Dim wb As Workbook[/FONT]
[FONT="]Set wb = ThisWorkbook[/FONT]
[FONT="]Dim ruta As String, ruta2 As String, ruta3 As String, ruta4 As String, nFile As String[/FONT]
[FONT="]nFile = Format(Date, "dd-mmm-yyyy")[/FONT]
[FONT="]ruta = wb.Path & ""[/FONT]
[FONT="]ruta2 = ruta & "export"[/FONT]
[FONT="]If Dir(ruta2, vbDirectory) = Empty Then[/FONT]
[FONT="]MkDir ruta2[/FONT]
[FONT="]End If[/FONT]
[FONT="]ruta3 = ruta2 & "PDF"[/FONT]
[FONT="]If Dir(ruta3, vbDirectory) = Empty Then[/FONT]
[FONT="]MkDir ruta3[/FONT]
[FONT="]End If[/FONT]
[FONT="]ruta4 = ruta3 & nFile & ""[/FONT]
[FONT="]If Dir(ruta4, vbDirectory) = Empty Then[/FONT]
[FONT="]MkDir ruta4[/FONT]
[FONT="]End If[/FONT]
[FONT="]<<<<Macro to create pdf as above steps and save it to ruta4 location>>>>>
[/FONT]
[FONT="]End Sub[/FONT]