Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
;Winbatch 2006C - Convert Publisher Document To Image File ; ;Use the SaveAsPicture() method which is a member of ;the Application's Page(s) Object. In Office 2003, the ;image format is determined by the file extension of the ;desired image file, i.e. bmp jpg gif [pretty neat] ; ;Stan Littlefield, June 22 2006 ;////////////////////////////////////////////////////////////////////// GoSub udfs IntControl(73,1,0,0,0) If ! isInReg("Publisher.Application") Display(1,"Cannot Continue","Publisher Object Not Available") Exit EndIf cPub = StrCat(DirScript(),"mortgage.pub") If ! FileExist(cPub) Display(1,"Cannot Continue - File Not Found",cPub) Exit EndIf cExt = ".GIF" nPage = 1 oPub = CreateObject("Publisher.Application") oPub.Open(::FileName=cPub) oPub.ActiveWindow.Visible=1 crImage() oPub.ActiveDocument.Close() oPub.Quit() oPub=0 Exit :WBERRORHANDLER ErrorProcessing(0,1,0) oPub=0 Exit ;///////////////////////////////////////////////////////////////////////// :udfs #DefineFunction isInReg(cProg) Return( RegExistKey(@REGCLASSES,cProg) ) #EndFunction #DefineSubRoutine crImage() IntControl(73,1,0,0,0) cOut = StrReplace( StrUpper(cPub),".PUB",cExt) BoxOpen("Please Wait",StrCat("Creating Image File",@CRLF,cOut)) If FileExist(cOut) Then FileDelete(cOut) oPub.ActiveDocument.Pages(nPage).SaveAsPicture(::FileName=cOut) If FileExist(cOut) BoxText(StrCat(cOut," successfully created")) Else BoxText(StrCat(cOut," creation failed")) EndIf TimeDelay(1) BoxShut() Return(1) :WBERRORHANDLER ErrorProcessing(0,1,0) BoxShut() Return(0) #EndSubRoutine #DefineSubRoutine ErrorProcessing(deleteIni,showerr,logfile) WbError = LastError() WbTextcode = WbError If WbError==1668||WbError==2669||WbError==3670 ; 1668 ; "Minor user-defined error" ; 2669 ; "Moderate user-defined error" ; 3670 ; "Severe user-defined error" WbError = ItemExtract(1,IntControl(34,-1,0,0,0),":") WbTextcode = -1 EndIf WbErrorString = IntControl(34,WbTextcode,0,0,0) WbErrorDateTime = TimeYmdHms() WbErrorFile = StrCat(DirWindows(0),"WWWBATCH.INI") If deleteIni FileDelete(WbErrorFile) IniWritePvt(WbErrorDateTime,"CurrentScript",WbErrorHandlerFile ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorValue" ,WbError ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ErrorString" ,WbErrorString ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptLine" ,WbErrorHandlerLine ,WbErrorFile) IniWritePvt(WbErrorDateTime,"ScriptOffset" ,WbErrorHandlerOffset ,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarAssignment",WbErrorHandlerAssignment,WbErrorFile) IniWritePvt(WbErrorDateTime,"VarInSegment" ,WbErrorInSegment,WbErrorFile) IniWritePvt("","","",WbErrorFile) EndIf WbErrorMsgText = StrCat(WbErrorDateTime,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Current Script: ",WbErrorHandlerFile,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error# [",WbError,"]",@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Error Text: ",wberrortextstring,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"[Extended Information] ",wberroradditionalinfo,@CRLF,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"On Line:",@CRLF,WbErrorHandlerLine,@CRLF) WbErrorMsgText = StrCat(WbErrorMsgText,"Offset: ",WbErrorHandlerOffset,@CRLF) If (WbErrorHandlerAssignment>"") Then %WbErrorHandlerAssignment% = "UNKNOWN" WbErrorMsgText = StrCat(WbErrorMsgText,"Assignment/Variable: ",WbErrorHandlerAssignment,@CRLF) If (WbErrorInSegment>"") Then WbErrorMsgText = StrCat(WbErrorMsgText,"In UDF/UDS: ",WbErrorInSegment,@CRLF) If logfile cSep = StrCat(StrFill("=",50),@CRLF) cLogFile = StrCat(DirScript(),"log.err") If ! FileExist(cLogFile) Then FilePut(cLogFile,StrCat("Error Log",@CRLF,cSep)) FilePut(cLogFile,StrCat(FileGet(cLogFile),WbErrorMsgText,cSep)) EndIf If showerr Then Message("wbErrorHandler",WbErrorMsgText) Return(1) #EndSubRoutine Return ;/////////////////////////////////////////////////////////////////////////
Article ID: W17198
File Created: 2007:07:03:14:28:42
Last Updated: 2007:07:03:14:28:42