
dpollard
Members-
Posts
18 -
Joined
-
Last visited
dpollard's Achievements

Seeker (1/7)
0
Reputation
-
Insert footer text in a word document - (Moved)
dpollard replied to dpollard's topic in AutoIt General Help and Support
Hi Water, Thanks for the point in the right direction. I managed to figure it out from the help once I knew were to look. My script now warns the user of the files that can't be modified and carries on which is exactly what I want to happen :) -
Hi Guys, I'm writing a script that loops through all the word documents in a given folder and inserts text into the footer. This is mostly working great. I have run into a problem where the footer in a few documents is somehow protected. If I open word manually I can select the text in the footer but I can't add to it. I can update the main text in the document so it isn't simply password protected. Rather than try and unprotect it I'm happy just to skip over it. I currently get an error on the line shown below $oRange.Inserafter ; Insert the text $oRange.Insertafter($text1 & $LastSavedDay &'/'& $LastSavedMonth &'/'& $LastSavedYear & $text2) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Insert Modified Date", _ "Error 010 Setting first footer InsertAfter location" & $file & @CRLF & "@error = " & @error & ", @extended = " & @extended) "E:\FileConversion\InsertCreationDate2.au3" (120) : ==> The requested action with this object has failed.: $oRange.Insertafter($text1 & $LastSavedDay &'/'& $LastSavedMonth &'/'& $LastSavedYear & $text2) $oRange^ ERROR It stops at the above line and does not get to the @error statement. I guess what I really need is to catch this error and jump to the next document in my for next loop. I'm happy to add the entire script to this post if anyone thinks that will help. Any Ideas? David
-
Solution: I did a "Repair" of Microsoft Office from Programs and Features then rebooted. It all tested OK after that. Thanks Water for you help diagnosing this one. David
-
_wordDocPrint only prints to default printer
dpollard replied to dpollard's topic in AutoIt General Help and Support
Hi Water, Sorry for the slow reply. For some reason even though am "Following" this thread I'm not getting email notifications of any new posts. Anyway, I have checked the spelling of my printer name and the case was spot on. My workstation name seems to be all in upper case. I have tried a couple of different combinations but it stil doesn't print anything and the @error and @extended are still 00. I'm at a bit of a loss for what else to try? David -
I don't believe it. I changed the OutlookEX.au3 file back to it's original state and It works on the other machine at the office. (and fails on my development machine) So something must be wrong with my local install of MS Office 10
-
I have another machine at the office I can try. (again W7 64bit and Office 10 64bit) I'll have to take the .14's back out and recompile. I'll see if I can get to it tomorrow I'll post back here with my results. Thanks David
-
Hi Guys, I'm running Windows 7 64 bit and Office 2010 64bit. I am trying to print a word document and nothing comes out when I try to specify the printer by name. I have tried a shared network name and a local printer name and niether work. If I don't specify a printer and send it to the default printer it prints OK. I have compiled both 32 and 64bit exe's and they both do the same thing. I have made a cut down example to demonstraight the problem. I started with the example script so I should be very close. ;Test Print ;http://www.autoitscript.com/autoit3/docs/libfunctions/_WordDocPrint.htm #include <word.au3> Local $hWordApplication Local $hWordDocument Local $BackgroundPrint=0 Local $Copies=1 Local $Orientation=-1 ;(Current Default) Local $Collate=1 Local $Range=0 ;Entire document Local $PageFrom=0 ;Starting page when Range=3 Local $PageTo=0 ;Ending page when Range=3 Local $Pages=0 ;The page numbers to be printed seperated by commas when Range=4 Local $PageType=0 ;0=All, 1=Odd and 2=Even Local $Item=0 ;Local $printerName="\\vjraywks05\HPOfficejet6500" Local $printerName="HPOfficeJet6500" $hWordApplication = _WordCreate(@ScriptDir & "\Test.doc") $hWordDocument = _WordDocGetCollection($hWordApplication, 0) $hWordDocument.Range.Text = "This is some text to print." ;_WordDocPrint($hwordDocument) ;<--- This prints to the default printer _WordDocPrint($hWordDocument, $BackgroundPrint, $Copies, $Orientation, $Collate, $PrinterName, $Range, $PageFrom, $PageTo, $Pages, $PageType, $Item) MsgBox(0,"Debug","Print Document=" &@error & @extended) _WordQuit($hWordApplication, 0) My Message box after the _WordDocPrint() command returns 00. Any Ideas where I'm going wrong. David PS I did post this question a month or two ago. I thought I solved it but the default printer was just tricking me.
-
Hi Water, I made the above change and we are making progress. It now works if Outlook is already running. If Outlook isn't running my message boxes report the following . MsgBox From OutlookEX.au3 OL_OPEN Status @error,@extended = -2147221021 , 0 Outlook Already Running = '' (that is two single quotes togeather.) MsgBos From TestEmail.au3 OL_Open Status @error,@extended = 1, -2147221005 AutoIt Error Line 5068 (File "<path to executable>") Error Variable must be of type "Object". Both 32 and 64bit compiles produce the same errors. I spotted this code further down in OUtlookEX.au3 If Not $bOL_AlreadyRunning Then $oOL = ObjCreate("Outlook.Application") And I also changed Outlook.Application to Outlook.Application.14 Now it seems to work perfectly. I guess now you need to figure out how to make the code generic for different versions of outlook. Hope this helps. Let me know if you would like me to assist in testing future versions. Thanks David
-
A little more diagnosis. I added the following Message Boxes to OutlookEX.au3 as follows (around line 176) Func _OL_Open($bOL_WarningClick = False, $sOL_WarningProgram = "", $iOL_WinCheckTime = 1000, $iOL_CtrlCheckTime = 1000, $sOL_ProfileName = "", $sOL_Password = "") Local $iOL_ErrorHandler = 0 Local $oOL = ObjGet("", "Outlook.Application") Msgbox (0,"OutlookEX.au3", "OL_Open Status (@error, @extended)=" & @error & "," & @extended) MsgBox(0,"OutlookEX.au3","Outlook Already Running ($oOL 0=Not Running)=" &"'" & $oOL &"'") Both 32 and 64 bit test.exe's produce the same results when Outlook is open or closed. The first message box reports -2147221005,0 The second message box reports that $oOL is blank. (i.e. to single quotes togeather)
-
I had a bit of a think about returning the error codes and I was probably making it harder than it needed to be. I added the following line of code direclty after the _OL_Open line $oOL = _OL_Open() Msgbox (0,"DEBUG", "OL_Open Status (@error, @extended)=" & @error & "," & @extended) 64bit exe reported the follwoing values @error = 1 and @extended = -2147221005 32bit exe reported the same values. Hope this helps diagnose the problem David
-
Hi Water, Thanks for taking the time to look into this. Outlook runs from here C:Program FilesMicrosoft OfficeOffice14 not the C:Program Files (x86) folder so that tells me it is the 64bit version. I have been compiling in 32bit. I just compiled in 64bit and a program named TestEmail_x64.exe was created. This generated the same error message. I don't know how to catch the values of @error and @extended from _OL_Open Can you give me a point in the right direction please? Thanks David
-
More Details I made a cut down example to demo the problem #include <OutlookEX.au3> Local $TO = "[email="email@gmail.com"]email@gmail.com[/email]" Local $CC = "" Local $BCC = "" Local $Subject = "Change Of Address" Local $Body = "This is the Body of the Email" Local $Attachments = "" Local $HTMLFormat = $olFormatHTML Local $Importance = $olImportanceNormal $oOL = _OL_Open() MsgBox(0, "DEBUG", "Email Address=" & $TO) MsgBox(0, "DEBUG", "Subject=" & $Subject) MsgBox(0, "DEBUG", "Body=" & $Body) MsgBox(0, "DEBUG", "Format=" &$HTMLFormat) MsgBox(0, "DEBUG", "Importance=" & $olImportanceNormal) ;_OL_Wrapper_SendMail($oOL[, $sTo = ""[, $sCc= ""[, $sBCc = ""[, $sSubject = ""[, $sBody = ""[, $sAttachments = ""[, $iBodyFormat = $olFormatUnspecified[, $iImportance = $olImportanceNormal]]]]]]]]) _OL_Wrapper_SendMail($oOL, $TO, $CC, $BCC, $Subject, $Body, $Attachments, $HTMLFormat, $Importance) MsgBox(0, "Debug", "SendMail Error=" & @error) I'm running on W7 64bit. Outlook is version 2010 both fully patched. The full error message is C:LocalChangeOfAddressOutlookEX.au3 (983) : ==> Variable must be of type "Object".: Local $oOL_Namespace = $oOL.GetNamespace("MAPI") Local $oOL_Namespace = $oOL^ ERROR ->16:57:01 AutoIT3.exe ended.rc:1 >Exit code: 1 Time: 10.619 Hope this helps. David
-
Hi Water, Firstly let me say you have done a great job with this UDF. You have gone to a lot of trouble. I'm trying to use the wraper to send an email and I'm getting a strange error from within the include file. Here are the lines of code to create the email. $oOL = _OL_Open() _OL_Wrapper_SendMail($oOL, $guiControlArray[$p][$EmailAddress], "", "", $clipboard, "", $olFormatHTML, $olImportanceNormal) I believe all those varables are set correctly. When I execute the script I receive the follwoing message. C:\Local\ChangeOfAddress\OutlookEX.au3 (983) : ==> Variable must be of type "Object".: Local $oOL_Namespace = $oOL.GetNamespace("MAPI") Local $oOL_Namespace = $oOL^ ERROR ->12:01:28 AutoIT3.exe ended.rc:1 Google didn't hlep me. Any ideas where I'm going wrong. Thanks in advance David
-
Diagnose Word Printing Problem
dpollard replied to dpollard's topic in AutoIt General Help and Support
Office is 64bit I think. Winword.exe is not in the program files 32 folder. I haven't changed any of the autoit settings so I'm assuming it is compiling in 32 bit. How do I tell if it is compiling in 32 or 64 bit. When I deploy it could be run on either architecture which is why I was hoping to get it to work in std 32 bit. Thanks David -
Hi Everyone, I'm trying to print a word document but nothing goes to the print queue and I'm not getting any error messages. I'm using the word.au3 include file and the _WordDocPrint function. I'm stumped as to what I'm doing wrong. It is part of a larger app but I have cut it down to the bare bones in this example to demonstrait the problem. All my message boxes return success (0) or (00) I'm using Office 2010 on Windows 7 64bit. Any assistance greatly appricated. #include <word.au3> Global $DoNotSaveChanges = 0 Global $hWordApplication Global $hWordDocument $hWordApplication = _WordCreate("") MsgBox(0,"Debug","Open Word=" &@error& @extended) $hWordDocument = _WordDocOpen($hWordApplication, @ScriptDir & "\templates\test.docx") MsgBox(0,"Debug","Open Document=" &@error& @extended) ;Print the Document _WordDocPrint($hWordDocument,"HPOfficeJet6500") MsgBox(0,"Debug","Print Document=" &@error & @extended) ;Close the document _WordDocClose($hWordDocument,$DoNotSaveChanges) MsgBox(0,"Debug","Close Document=" &@error& @extended) ;Exit Word _WordQuit($hWordApplication,0) MsgBox(0,"Debug","ExitWord=" & @error @extended)