Ravel Posted August 17, 2007 Posted August 17, 2007 I am fairly familiar to writing scritps with Autoit, but only basic scripts. What I am asking help on is over my head. I currently have a script that i use to transfer files from one folder to multiple others and divy them up according to the name of the file. What i would like to do is during the process of transfering the files have them converted from .doc to .pdf. I use this script at work to transfer files, but the only programs that i have installed to do this is an add in for word 2007, and PDF reDirect. I am not sure how to automate this process, and would like to know if someone here can provide assistance. Here attached the script that I am currently using to tranfer the files.copyreports.au3
weaponx Posted August 17, 2007 Posted August 17, 2007 Maybe you could use _WordDocPrint and print to a PDF printer.
weaponx Posted August 17, 2007 Posted August 17, 2007 This will use the builtin Word functions with CutePDF printer installed (freeware): #include $oWordApp = _WordCreate ("") $oDoc = _WordDocOpen ($oWordApp, @ScriptDir & "\TODO.doc") $oDoc = _WordDocGetCollection ($oWordApp, 0) _WordDocPrint ($oDoc, 0, 1, 0, 1, "CutePDF Writer") ;WinWaitActive ( "Save As" ) $SET = ControlSetText ( "Save As", "", "Edit1", "test.pdf") If $SET = 0 Then MsgBox(0,"","Error changing filename") ControlClick ( "Save As", "", "Button2" ) _WordQuit ($oWordApp, 0)
ptrex Posted August 19, 2007 Posted August 19, 2007 @AllMaybe this can get you all started.PDFCreator in AU3regards,ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Ravel Posted August 20, 2007 Author Posted August 20, 2007 This will use the builtin Word functions with CutePDF printer installed (freeware): #include $oWordApp = _WordCreate ("") $oDoc = _WordDocOpen ($oWordApp, @ScriptDir & "\TODO.doc") $oDoc = _WordDocGetCollection ($oWordApp, 0) _WordDocPrint ($oDoc, 0, 1, 0, 1, "CutePDF Writer") ;WinWaitActive ( "Save As" ) $SET = ControlSetText ( "Save As", "", "Edit1", "test.pdf") If $SET = 0 Then MsgBox(0,"","Error changing filename") ControlClick ( "Save As", "", "Button2" ) _WordQuit ($oWordApp, 0) I was looking at this... Since this is a company computer, I will not be able to install CutePDF writer. They already have PDFRedirect installed so I either have to use that or use the Microsoft 2007 Add in pdf converter. Is there anyway of taking this code and using the pdf add in? here is the link to the add in that I am referring to: 2007 Microsoft Office Add-in: Microsoft Save as PDF It is important to note that I cannot install any new software, I have to use either PDF Redirect, or the above add in. Any thoughts?
Ravel Posted August 20, 2007 Author Posted August 20, 2007 @AllMaybe this can get you all started.PDFCreator in AU3regards,ptrexWell I tried looking to implement that but it looks greek to me. I also couldn't use it because i can install pdf Creator on this pc.
weaponx Posted August 20, 2007 Posted August 20, 2007 (edited) It looks like there is a VBScript that uses the Save-As PDF add in here : http://www.suodenjoki.dk/us/productions/ar...es/word2pdf.htmI only have Office 2003 so I will not be much help testing.You could attempt an automatic VBScript to AutoIT conversion: http://www.autoitscript.com/forum/index.php?showtopic=12143 Edited August 20, 2007 by weaponx
Ravel Posted August 20, 2007 Author Posted August 20, 2007 It looks like there is a VBScript that uses the Save-As PDF add in here : http://www.suodenjoki.dk/us/productions/ar...es/word2pdf.htmI only have Office 2003 so I will not be much help testing.You could attempt an automatic VBScript to AutoIT conversion: http://www.autoitscript.com/forum/index.php?showtopic=12143Thanks I have checked it out. It looks promising. I'll have to see if I can figure it out.
Ravel Posted August 21, 2007 Author Posted August 21, 2007 (edited) It looks like there is a VBScript that uses the Save-As PDF add in here : http://www.suodenjoki.dk/us/productions/ar...es/word2pdf.htmI only have Office 2003 so I will not be much help testing.You could attempt an automatic VBScript to AutoIT conversion: http://www.autoitscript.com/forum/index.php?showtopic=12143Ok, I was looking at the the file. I changed it over to .au3, but for the life of me I cannot find where I am supposed to input the file that I want to convert. On top of that The file that I originally attached has a lot of separate lines to move separate files. Will I have to take this converted script and create one script for each of the lines i have in the original script?doc2pdf.au3ORIGINALcopyreports.au3 Edited August 21, 2007 by Ravel
weaponx Posted August 21, 2007 Posted August 21, 2007 Looks like you call the function like this: DOC2PDF( $sDocFile, $sPDFFile ) $sDocFile is the path to your Word Doc $sPDFFile is the output name of your pdf
Ravel Posted August 21, 2007 Author Posted August 21, 2007 Looks like you call the function like this:DOC2PDF( $sDocFile, $sPDFFile )$sDocFile is the path to your Word Doc $sPDFFile is the output name of your pdfLOL I completely missed that section of the script. Let me give that a try. Also on another note is there away to incorporate what I already have into this script? I mean that is a lot of lines that I have. It seems that it would be possible, but I am not sure yet. Any thoughts?
weaponx Posted August 21, 2007 Posted August 21, 2007 (edited) Maybe like this: #include "doc2pdf.au3" While 1 DOC2PDF( "\\P533FP2\MATCTRL_REPORTS\208-280TH (METNAV)\JANUARY 07\11-04. D23 Daily Report*.doc", "\\P533FP2\45SW_ERM\45SCS_SCBMM\15 - Priority Monitor Report\15-B - D231 January\*.doc" ) ;etc... WEnd I'm not sure if it will create folders if they don't already exist. EDIT: Also why are you using Sleep after each filecopy? It won't attempt the next copy until the previous completes so this is wasteful. Edited August 21, 2007 by weaponx
weaponx Posted August 21, 2007 Posted August 21, 2007 I just realized that you were using a wildcard for the source and destination. You will have to do a FileListToArray on each folder and call the function for each item in the array.
Ravel Posted August 21, 2007 Author Posted August 21, 2007 (edited) Maybe like this: #include "doc2pdf.au3" While 1 DOC2PDF( "\\P533FP2\MATCTRL_REPORTS\208-280TH (METNAV)\JANUARY 07\11-04. D23 Daily Report*.doc", "\\P533FP2\45SW_ERM\45SCS_SCBMM\15 - Priority Monitor Report\15-B - D231 January\*.doc" ) ;etc... WEnd I'm not sure if it will create folders if they don't already exist. EDIT: Also why are you using Sleep after each filecopy? It won't attempt the next copy until the previous completes so this is wasteful. Really? I didn't realize that. I can remove the sleep command. As for the creation of the folders, I designed it to do that so that the folders would be created if they were not already there. Also if I am include the doc2pdf.au3 won't i have to specify what file would be converted in that script or is it set up default as a wildcard, allowing me to just add it to the my original script? At the end were it would have originally just transferred the file to the new folder as a doc, wont i have to make the destination .... January\*.pdf" instead? I just realized that you were using a wildcard for the source and destination. You will have to do a FileListToArray on each folder and call the function for each item in the array. I don't quite no what the filelistToArray is, but i'll look it up in the help file to see if I can figure it out. EDIT: I was running the script... doc2pdf.au3 and I am getting a syntax error at 22,7? not sure what this is really asking me to correct. I am assuming that this is the $ symbol before the W, but not sure what that means. Edited August 21, 2007 by Ravel
weaponx Posted August 21, 2007 Posted August 21, 2007 Line 22: $onst $WdDoNotSaveChanges = 0 Should probably be Const $WdDoNotSaveChanges = 0
Ravel Posted August 21, 2007 Author Posted August 21, 2007 I just realized that you were using a wildcard for the source and destination. You will have to do a FileListToArray on each folder and call the function for each item in the array.Is that in the help file? I can't seem to find it
Ravel Posted August 21, 2007 Author Posted August 21, 2007 (edited) When I run this script i am getting all sorts of errors, and I cannot figure out how to solve them. Anyone else have any suggestions? Edited August 21, 2007 by Ravel
Ravel Posted August 22, 2007 Author Posted August 22, 2007 When I run this script i am getting all sorts of errors, and I cannot figure out how to solve them. Anyone else have any suggestions?Bump..Can anyone help with these scripts.
weaponx Posted August 22, 2007 Posted August 22, 2007 I'm throwing something together for you. The vbscript that you converted had a few errors, I cleaned it up and will post it along with a method for using wildcards soon.
Ravel Posted August 22, 2007 Author Posted August 22, 2007 I'm throwing something together for you. The vbscript that you converted had a few errors, I cleaned it up and will post it along with a method for using wildcards soon.Thanks I appreciate it!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now