vba print pdf file without opening

Page 1

CLICKHERETO DOWNLOAD

IamnotgeneratingthePDFswiththeAccessDBtheyarecreatedbyanotherapplicationandstoredonanetworkdrivesCmd="Start-Process-FilePath'"& sFile&"'-VerbPrint".I'mlookingforacodetoprintmyexcelfileswithoutopenit.StepWecallthePrintOutmethodonthespecifiedrange.ForWindows.vPID =Shell(", I'mtryingtoprintthePDf-file(s)inacertainfolder(oralternativelyjustprintthefilesone-by-one)usingforexampleMicorosftPrinttoPDFinorder tocreateflattenedversions(VBA-/PowerShell-)script,butI'mnotveryexperiencedatthatPrintpdffilewithoutopeningPrintDialogusingwindowsform applicationPrint, ThissolutionrequiresareferencetotheWordlibrarytobesetinExcel(Tools,references)Subtest()DimsAsStringDimtAss="\\my path\my"DimwdAsNewationDimmydocAsntSetmydoc=(Filename:=s,Format:="PDFFiles",StepNext,wereferenceaspecificworksheetin “ThisWorkbook”using(“Sheet1”)IamusingAccess,andtryingtoprintoutmultipleexternalPDFfilessilently(withoutopeningAdobeReaderoraprintdialog) IamusingAccess,andtryingtoprintoutmultipleexternalPDFfilessilently(withoutopeningAdobeReaderoraprintdialog).There'safewthreadsaboutthis, butnothingseemstobeworkingformeInthisarticle,wewillguideyouthroughtheprocessofutilizingExcelVBAtoprintPDFfileswithoutthehassleofopening themonebyoneSorryifiseemtoorepetitivebutIreallywantaHello!ItistherangethatwewanttoprintToprintanencryptedfile,selectthe[Setting Password]checkbox,andthenenterthepassword, OptionExplicitFunctionRDBCreatePDF(SourceAsObject,FixedFilePathNameAsString, OverwriteIfFileExistAsBoolean,OpenPDFAfterPublishAsBoolean)AsStringDimFileFormatstrAsStringDimFnameAsVariantIfFixedFilePathName="" ThenFileFormatstr="PDFFiles(*pdf),*pdf"Fname=DimsCmdAsStringPrivateSubCommand22Click()DimvPIDAsVariantCode:Copyto clipboardInthiscase,weincludeoptionalparametersI'mtryingtouseVBAtoprintanumberofPDFfilesinafolder(C:\Users\Tim\Desktop\CSV\)without openingallofthem.CallPSExecute(sCmd)andyouwouldthensimplycallitbydoing:SowithasinglePowerShellcommandandthePSExecutesubfrom VBA–RunPowerShellCommandwecannowprintanyfileswithouttheneedofanyAPIs, hi@oxicottinyoucantrythiscode,butyouhavetochangetheto thenameoftheexecutablefileofadobeacrobatreader,ithinkitis,butpleaseconfirmpdffilename=Thepdffilenameisthetexttheuserwillenterandwiththe clickofbutton1itwillstorethatasstringandshouldaddP:\extensionattheendofitandshouldreplacethatpartofme="P:\"Thefourparametersofthe/t optionevaluatetopath,printername,drivername,andportname(allstrings)Code:DimpdffilenameasStringRight-clickaPDFfiletoprint,andthenselect[PDF PrintDirect]StepWithinthisworksheet,wespecifyarangeusingRange(“A1:B10”)Tosettheuserauthenticationfunctionwiththeselectedprinter,select[User Auth]fromthe[PrinterSetting]menuSelectaprintertouseFoundsomecodeslike"PrintOut"functionorothersbutwithoutopenit,doesn'tseemstoworkTry thiscommandforusingacrobatreader:AcroRdexe/tpathprinternamedrivernameportnameInitiatesAcrobatReader,printsafilewhilesuppressingtheAcrobat printdialogbox,thenterminatesReaderI'vedoneabunchofsearchesIamnotgeneratingthePDFswiththeAccessDBtheyarecreatedbyanotherapplication andstoredonanetworkdriveOpenotherfiles(mightbealooptoopennowandprint1XfilesmakesitreallylongtocalculateWewillcovereverythingfrom savingPDFattachmentstosettingthedesiredprinterandhandlingpotentialerrors="print"Style=nts=ng()me="P:\"'Needtoreplacethiswithastringbased onthetextbox1inputandtothestringandthelocationofitfor(psi)EndSub#Hello!

Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.