Saving all worksheets to seperate PDF files but excluding ...
文章推薦指數: 80 %
I am a bit new to VBA coding but have managed to create a macro ... through all worksheets and save as individual PDF in same folder 'as the ... OzGridFreeExcel/VBAHelpForum Forum HELPFORUMS ExcelVBA/Macros FreAnd Beginner Points 25 Posts 3 OperatingSystem Windows(x64) ExcelVersion Excel2019 [xpost][/xpost]https://www.mrexcel.com/board/…files-vba-coding.1195462/Hiall,IamabitnewtoVBAcodingbuthavemanagedtocreateamacrothatletsmesavemultipleworksheetstoseparatepdf's.But,Idon'twanttoincludetwospecificsheets,forex,sheetTEMPLATEandSOURCEDATAhowcanIexcludethesetwoandprinttherest?Thisismycode: Code SubLoopSheetsSaveAsPDF() 'Createvariables DimwsAsWorksheet 'LoopthroughallworksheetsandsaveasindividualPDFinsamefolder 'astheExcelfile ForEachwsInActiveWorkbook.Worksheets ws.ExportAsFixedFormatType:=xlTypePDF,_ Filename:=ThisWorkbook.Path&"/"&ws.Name&".pdf" Next EndSub DisplayMore IwouldbeverygratefulforanyassistanceMybestregardsfromacoldSweden,Fredrik FreAnd Beginner Points 25 Posts 3 OperatingSystem Windows(x64) ExcelVersion Excel2019 TheclosestIcangetiswiththisIFnotstatment,NowIcanexcludetheSourcedatasheetbutstillnottheTemplatesheet, Code SubLoopSheetsSaveAsPDF() 'Createvariables DimwsAsWorksheet 'LoopthroughallworksheetsandsaveasindividualPDFinsamefolder 'astheExcelfile ForEachwsInActiveWorkbook.Worksheets IfNotws.Name<>"Template"Orws.Name<>"Sourcedata"Then ws.ExportAsFixedFormatType:=xlTypePDF,_ Filename:=ThisWorkbook.Path&"/"&ws.Name&".pdf" Else EndIf Next EndSub DisplayMore royUK SuperModerator ReactionsReceived 807 Points 133,817 Posts 26,394 OperatingSystem Windows(x64) ExcelVersion Office365 WelcometotheForum.PleasereadtheForumRulestounderstandhowtheForumworksandwhyIhaveaddedCodeTagstoyourpostAllVBAcodepostedintheforummustbewrappedincodetags,whichyouomitted,includingsingle-linecodesnippets.Besuretousetheminfutureposts.HowtousecodetagsJusthighlightallofthecodeandpressthe<>inthepostmenuabovebuttontoaddthecodetags.Thanks. royUK SuperModerator ReactionsReceived 807 Points 133,817 Posts 26,394 OperatingSystem Windows(x64) ExcelVersion Office365 Trythis Code SubLoopSheetsSaveAsPDF() 'Createvariables DimwsAsWorksheet 'LoopthroughallworksheetsandsaveasindividualPDFinsamefolder 'astheExcelfile ForEachwsInActiveWorkbook.Worksheets SelectCasews.Name Case"Template","Sourcedata" ''///ignorethesesheets CaseElse ws.ExportAsFixedFormatType:=xlTypePDF,Filename:=ThisWorkbook.Path&"/"&ws.Name&".pdf" EndSelect Nextws EndSub DisplayMore FreAnd Beginner Points 25 Posts 3 OperatingSystem Windows(x64) ExcelVersion Excel2019 HiRoy,Thankyouverymuch,nowitworks!WentthroughtheForumRulestoofast(asusuallyWilltakeacloserlookandmakesuretowrapinCodeTagsnexttimeAgain,Thankyou!BestregardsFredrikVBAPadawan royUK SuperModerator ReactionsReceived 807 Points 133,817 Posts 26,394 OperatingSystem Windows(x64) ExcelVersion Office365 Also,readalltheRules,specificallyCrossPosting.Cross-postingiswhenyoupostthesamequestioninotherforumsontheweb.You'llfindpeoplearedisinclinedtorespondtocross-postsbecausetheymaybewastingtheirtimesolvingaproblemthathasbeensolvedelsewhere.Wepreferthatyounotcross-postatall,butifyoudo(andit'sunlikelytogounnoticed),youMUSTprovidealink(copytheURLfromtheaddressbarinyourbrowser)tothecross-post.Weareheretohelpsohelpushelpyou!Readthistounderstandwhyweaskyoutodothishttps://www.excelguru.ca/content.php?184 Participatenow! Don’thaveanaccountyet?Registeryourselfnowandbeapartofourcommunity! RegisterYourself Login Share Facebook Twitter Reddit WhatsApp LinkedIn Pinterest XING Tags VBAMAGIC Navigation OzGrid Excel/VBAConsultancy OzGridStore Training Freebies Forum UnresolvedThreads ForumRules Dashboard Articles PrivacyPolicy Search Options CurrentLocation OzGridFreeExcel/VBAHelpForum Forum HELPFORUMS ExcelVBA/Macros UserMenu Loginorregister Thissiteusescookies.Bycontinuingtobrowsethissite,youareagreeingtoouruseofcookies. MoreDetails Close
延伸文章資訊
- 1VBA - Save Invoice Worksheet as PDF - to Specific Folder
- 2Save excel as PDF in current folder using current workbook ...
Save an Excel PDF sheet in the same directory as my Excel file
- 3How to Save a PDF File with a Specific User-Defined Path in ...
A simple VBA macro program script will be able to open or display a dialog window, asking the use...
- 4Excel VBA Save As PDF: Step-By-Step Guide And 10 Examples
If you're creating a macro to save Excel files as PDF, and those PDF files must always be saved i...
- 5VBA creating pdf files and saving them in the same folder ...
I am trying to create individual pdf file for three active sheets (Report1, Report2 and Report3) ...