Saving all worksheets to seperate PDF files but excluding ...

文章推薦指數: 80 %
投票人數:10人

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



請為這篇文章評分?