Excel vba print selection to pdf12/28/2023 ![]() If fName "Master1.xls" And fName "Master2.xls" Then 'or. 'wbNew.Sheets().Name = wbNew.Sheets().Cells(1, 1)Īpplication.Calculation = xlCalculationAutomatic Sheet.Copy After:=wbNew.Sheets()ĪctiveSheet.Name = ActiveSheet.Range("F6") Workbooks.Open FileName:=FolderPath & FileName, ReadOnly:=True ![]() 'wbNew.SaveAs FileName:="C:\Users\swaroopa.bp\Desktop\C\Consolidation", FileFormat:=xlWorkbookNormalĪpplication.Calculation = xlCalculationManual Quality:=xlQualityStandard, IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=Falseĭim wbOpen As Workbook, wbNew As Workbook, fName As String, strPath As Stringĭim FolderPath As String, fldr As FileDialog, sItem As String, FolderName As Stringĭim FileName As String, Sheet As Worksheet Range("A1:E20").ExportAsFixedFormat Type:=xlTypePDF, Filename:=FolderName & "\" &. At first I thought I could have a VBA macro on the sheet do this by a series of 'print as PDF', but that requires an intermediary interactive dialog box to specify the output file name. Range("C14").Value = Worksheets("Sheet2").Range("B" & i).Value I want to run the spreadsheet automatically from the command line, and have it automatically save all three reporting sheets as a PDF file(s). 'File_Name = FolderName & "\" & File_Name & ".xlsm" ' Create a path by combining the file and folder names: ' If the user didn't select anything, you can't save, so tell them so: InitialFileName = Application.DefaultFilePath Set fldr = Application.FileDialog(msoFileDialogFolderPicker) LastRow = Worksheets("Sheet2").Cells(Rows.Count, 2).End(xlUp).Row operation repeats with row 3 and so on to the last non-empty row in column B of my source tableĭim i As Long, LastRow As Long, FolderPath As Stringĭim fldr As FileDialog, sItem As String, FolderName As String.code prints template to pdf and takes the name from the same row in source table (my table has headers, so it would be E2) and saves the pdf file under that name.code takes first value from source table (zaposleni B2) and paste in my template sheet 2) print the main spreadsheet to PDF, save it as 'PPK 2.71, the name as it appears on the dropdown, and date (for example PPK 2.71-1-200226) 3) select the next item in the drop down menu 4) print to pdf (for example PPK 2.I'm choosing existing or creating a new folder.But for example, I only want to print the Product 1 and Product 3 (skipping product 2), then I will only be able to print them into 2 separated pages. Browser window opens and ask me where I want to save my pdf files For example, in the photo below, you can see that if I select from the first row to the last row, then when I print Selection into PDF, it will be converted into 1 single page.The code is written to save your document in the same folder as the Excel file currently resides. I would add file names in my source table, sheet "zaposleni" in first empty column which is column "E" Below is a simple VBA macro that will allow you to quickly turn your selected worksheet(s) into a PDF file in a snap. ![]() As the path to the folder is required it would be also nice to add browser window (to avoid fixing the path in the code) so I could chose the folder in which my pdf files will be stored.This is ok if I want to save one by one manually or merge all in one pdf file, but what I need is the option of auto saving of each file as per specified name.Sorry that I took your time and couldn't give you a quick solution. In the meantime, please be patient, we have weekend :) I'm sure they will give you a specific or official answer. I think that one of Microsoft will take care of your question. The only thing I can do for you is this VBA code.īut since I don't have a 365 Office desktop version (like you, as far as I could see your written version) I can't help you any further. 'because I know that I don't know anything. 'Is just a suggestion doesn't have to be right. 'Check your code to see if you have used zoom correctly. ![]() XlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, _ VerzeichnisName & "\" & Name, Quality:= _ That's why I try (like some others here) to help voluntarily as far as I can.ĪctiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ Order not to be misunderstood, the goal of some Excel users in the community is to provide help with projects by Excel users, or rather to provide food for thought.Īs part of this excellent forum, my aim is to give help to get help where I can and need it.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |