Word automation - PrintOut - OLE exception [Edit]

We're migrating our system from Delphi 7 to Delphi XE 2 and have encountered a problem when using Word Automation to print customer letters. In this case our Delphi 7 solution works happily on Windows 7 32 bit, but the same code raises an OLE exception when compiled in Delphi XE 2.

Essentially we present the user with the standard print dialogue then issue the printout command. At this point we get an OLE exception.

Dlg := WPObject.Dialogs.Item(88);

WPObject.PrintOut(Background := false,
                        range     := dlg.Range,
                        From      := dlg.From,
                        To        := dlg.To,
                        PageType  := dlg.Type,
                        Copies    := dlg.NumCopies,
                        Pages   := dlg.Pages,
                        Collate  := dlg.Collate,
                        PrintToFile  := dlg.PrintToFile,
                        ManualDuplexPrint  := dlg.DuplexPrint,
                        PrintZoomColumn  := dlg.PrintZoomColumn,
                        PrintZoomRow  := dlg.PrintZoomRow,
                        PrintZoomPaperWidth  := dlg.PrintZoomPaperWidth,
                        PrintZoomPaperHeight  := dlg.PrintZoomPaperHeight);

Can anyone please advise us how to resolve the OLE exception, or suggest a word around.

Many thanks,

Edited by: Phil Riches on Feb 10, 2012 5:05 AM

Edited by: Phil Riches on Feb 10, 2012 5:06 AM
2/10/2012 1:06:38 PM
embarcadero.delphi.ole 598 articles. 1 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 25
Get it on Google Play
Get it on Apple App Store

Phil Riches wrote:

> We're migrating our system from Delphi 7 to Delphi XE 2 and have
> encountered a problem when using Word Automation to print customer
> letters. In this case our Delphi 7 solution works happily on Windows
> 7 32 bit, but the same code raises an OLE exception when compiled in
> Delphi XE 2.
> Essentially we present the user with the standard print dialogue then
> issue the printout command. At this point we get an OLE exception.
> Dlg := WPObject.Dialogs.Item(88);
> WPObject.PrintOut(Background := false...
> Can anyone please advise us how to resolve the OLE exception, or
> suggest a word around.

I am not used to Word OLE automation and so it's hard to guess what the
problem could be. In case you do use any Word constants somewhere in
the code before that calls than it could be related to the fact that
XE2 does dispatch enumerations as unsigned integers instead of signed

If you're affected by this particular issue then an integer typecast at
the right place (can't tell you where) or waiting for Update #4 might
help. Update #4 is supposed to have a new global variable that enables
the old behavior (XE and before). For more, but preliminary information
refer to

Uwe Schuster | Hero of the Delphi 2010 FT
2/11/2012 8:58:34 PM
This sounds likes in the same area, when the update is available I'll give it a try.
2/13/2012 10:50:11 AM
Thanks for your help, it looks like this was fixed in Upgrade 3 (we were running Upgrade 2). We believe this was raised as issue 99387. Whilst the symptoms appear a little different its a similar problem.

"Description:	Steps:
[QC Short Description]
[REGRESSION] On a late binding OLE call the "type := 33" results in a runtime tpe miss match error

[QC Description]
I am porting library function from XE to XE2 and came across a problem with OLE Objects which are OK in XE but produce a run time Type Mismatch error in XE2
QC Entry 99387
I am porting library function from XE to XE2 and came across a problem with OLE Objects which are OK in XE but produce a run time Type Mismatch error in XE2 When attempting to add a Field to a word document via OLE I get a run time Type Mismatch error which can be isolated to the type parameter; FMSWord.Selection.Fields.Add(Range := FMSWord.Selection.Range, type := wdFieldPage); wdFieldPage is a constant number. I tried passing as a variant also"

Thanks anyway,
2/13/2012 4:53:28 PM
Finally got round to installing and retesting Upgrade 3. It fixes the problem. Thanks for your help.
3/15/2012 6:18:29 AM

Similar Artilces:

Delphi 7 Excel automation [Edit]
None of the main categories make any sense for this post, but Excel is a form of reporting I guess, so I put it here. Fine if you decide to move it. Doesn't matter to me. In Excel, you can select individual or groups of characters within a cell and modify their characteristics, such as bold, font color, font name, etc. I know how to do this in VBA in Excel and Access. I've tried to apply this idea to some automation I'm doing from within D7 but it's not working. My Excel file is created as expected in every way other than this. OXL is a variant that is the workbook oShee...

[DELPHI XE] UTF8ToUnicodeString out of memory Exception [Edit]
Hello, I'm using the function below (in ~\rtl\Sys\System.pas) +*function UTF8ToUnicodeString(const S: PAnsiChar): UnicodeString; overload;*+ Length(S) = 223.224.276 bytes At this line : +*SetLength(Temp, L);*+ There is a "*Out Of Memory*" Exception. How can I make an UTF8 To UnicodeString conversion without exception? I've to cut my string? Any help will be appreciate. Thanks. Edited by: Gwénaël Manceau on Jan 17, 2012 1:10 AM Gwénaël Manceau schrieb: > Hello, I'm using the function below (in ~\rtl\Sys\System.pas) > >...

Delphi 2010 and Floating Point Exceptions [Edit]
Hello, I am trying to port a project from Delphi 7 to Delphi 2010 and for some unknown reason, floating point exceptions are not being thrown like division by zero. I have not been able to replicate the problem in a small project so I have no examples. The try/expect is in a unit seperate from the main program unit. Here is what I have tried: {$FINITEFLOAT ON} no changes I tried the Get8087CW and Set8087CW rountines. No changes. I took out all of the code surrounding my try/except clause except for the math Example try Val1:=14.23; Val2:=0.0; Val3:=Val1/Val2; except V...

Automated(Delphi 2) methods on IOS [Edit]
Although help says automated methods does work only on Win32, I've noticed that code contains it -- *does* compile and run on Mac OS, Iphone Emulator. But I have no Iphone device, so could someone test code I attached on Iphone hardware(not emulator)? http://www.load.to/zwyZaqVnHi/testIph.7z Edited by: Alexander Snigerev on Jul 6, 2013 1:03 AM Alexander Snigerev wrote: > http://www.load.to/OzetL8d3Eu/testAutomated.7z That's missing the file "Unit13.pas" and also the .dproj file. -- Dave Nottage [TeamB] Alexander Snigerev wrote: > Although help sa...

OleContainer automating Word how do you hide toolbars? [Edit]
I have an OLEContainer showing a word document in a tabbed notebook. I'm invoking the OLEContainer in the following manner: oleContainer1.CreateObjectFromFile(strFilename, false); oleContainer1.Run; oleContainer1.OleObject.Protect(wdAllowOnlyComments, EmptyParam, EmptyParam); oleContainer1.DoVerb(ovShow); When the Word document is first displayed the toolbars are shown (well technically it's the ribbon as I'm using Word 2010, but the customers aren't necessarily using this version). When the tab is switched then switched back to reshow the document t...

Delphi XE3 crashes when closing Word 2010 [Edit]
After changing from Delphi 6 to XE3 my program crashes when i close a Word-Document opened by the program using OLE-Automation. So i created a very simple Test-Program with only one Form, a TWordApplication and a TWordDocument (and of course a TButton...). On ButtonClick i connect to Word and open a document. If i close Word or the Document all is working fine. Then i assigned an eventhandler to WordApplication.OnDocumentBeforeClose. If i then close the Document my program crashes calling the eventhandler in TWordApplication.InvokeEvent. Has anyone seen this problem and maybe a so...

OfficeXP Automation
Hello, we had used the OfficeXP Automation Components in older Delphi Version. We uses for example the TItem Component, but in Delphi XE2 I don't find this (and other components) and so I'm not able to open or compile the project. The component List of the Office XP Automation Server was in Delphi XE much larger. What can I do to solve this problem? Best wishes Bernhard Edited by: Registered User on May 10, 2012 6:14 AM > What can I do to solve this problem? What if you install the Office 2000 packages instead of Office XP? (menu-component-install packages : uncheck Off...

Reference for Office 2007 Word and Excel Delphi Automation Components
Does anyone have a good reference for the Delphi automation components for Word and Excel? Most examples I've found on the web use late binding and the components are not needed. Even the examples on MSDN use late binding. The snytax of late binding appears to be VBA but I can't find a good Delphi reference for Office 2007 and VBA either. Unfortunately, Microsoft has made many changes to the automation model over the years and code from older examples usually does not work and require extensive modification. Again, there appears to be very little in the way of references for t...

Word Automation: CheckGrammar()
(Delphi® 2010 Version 14.0.3593.25826 ) I cobbled together some code (below) from across the interwebs for SPELL checking using MS Word. It works great. I am now trying to modify it to do GRAMMAR checking instead. Easy enough, I thought--replace .SpellingErrors/.CheckSpelling with .GrammaticalErrors/.CheckGrammar. .GrammaticalErrors appears to be working fine; however, I am getting an *+"EOleSysError...Invalid Number of Parameters" error on .CheckGrammar"+*. Occording to this: http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document_members.asp...

Corruption of dfm files following exception during Delphi shut-down [Edit]
Hi, I have a GUI application whose main form contains instances of 2 separate classes of frame. The frame classes in turn contain instances of a third class of frame. Yesterday after creating from scratch and testing the second frame (which was not inherited from any other frame) I saved the project then exited Delphi. During Delphi shut-down a Windows error message relating to the Delphi application appeared, and I was forced to kill the Delphi process. When I next reopened the project I was presented with Delphi error messages relating to inconsistencies between TActionList components ...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

Excel Automation: Exception OLESysError Member not found (DXE2) [Edit]
Hello, Quite amazing that by every new Delphi version I have to go through the Office automation. This time I don't know how to solve this "member not found: message. The following code is working fine in DXE but not in DXE2.. here my post when problems converting from D2007 --> D2010 https://forums.embarcadero.com/message.jspa?messageID=247469 {code} var XLChart : ExcelChart; XLRange : ExcelRange; ChartAxis : Axis; WSChartObjects : OLEVariant; WSChartObject : OLEVariant; oTrendLines: OLEVariant; Begin WSChartObjects := ChartObjects( FXLWS...

ANN: WPTools Special 18% off (word processing VCL for Delphi) [Edit]
WPTools, the native Delphi Express Texter! If you work with Delphi or C++Builder our WPTools Version 6 (http://www.wpcubed.com/products/wptools/features/index.htm) is the perfect text wordprocessing component for You. It is a native VCL Component with all the editing features which are common to powerful wordprocessing applications and wordprocessing controls. With the PRO and Premium License you get 100% object pascal source. WPTools can be used as a powerful word processor and to create programmatically controlled text. It has a very versatile mail-merge feature which can be enhanced ...

Help with word autocorrect automation with rich text format from access db [Edit]
Help! I am trying to automate autocorrect entries that are in rich text format stored in access db. It works fine if I use Add but fails with AddRichText. Look the code below. I would appreciate your help! Andrew procedure TfrmdxForm.autocorrectBtnClick(Sender: TObject); var DXRANGE, DXWORD: oleVariant; DXSTR: STRING; begin DXWORD := CreateOleObject('Word.Application'); DXWORD.Visible := FALSE; MyADODataSet.First; while NOT MyADODataSet.Eof do begin *DXRANGE:= MyADODataSet.FieldByName('DX').Text; // here where it fails … I don't know h...

Delphi 2010 and Word 2010 via COM/TypeLibrary and TWordApplication Win32 [Edit]
Hi there, I have a few tools that remotely control Word (v<2007) via TWordApplication that works fine. I downloaded Office 2010 Trial (incl. Word 2010, Excel 2010... To me is only Word 2010 important...) version and used firstly the the built-in wrappers of Delphi (Word2000 and WordXP) because I think I could handle my stuff via the old interfaces. I got an error "interface not supported CLSID {anyGUID...}", when I use e.g. myWordApp.Connect. I tried to import a new Office 2010 TypeLibrary but I couldn't find any? I don't wanna go via .NET or sth.... Is there any ...

Web resources about - Word automation - PrintOut - OLE exception [Edit] - embarcadero.delphi.ole

Automation - Wikipedia, the free encyclopedia
For a hierarchical presentation of automation topics, see Outline of automation . For other uses, see Automation (disambiguation) . Automation ...

Automation World - Covering the field of industrial automation
AutomationWorld.com delivers content for the Automation Buying team, which includes Information Technology and Networking; Operations and Engineering; ...

Facebook Ads API Partner AdStage: Campaign Automation, $6.25M Series A Funding
AdStage , a Facebook ads API partner, announced Wednesday the launch of campaign automation — as well as a $6.25 million round of Series A funding. ...

Facebook PMD IgnitionOne launches self-service marketing automation
IgnitionOne , a Facebook Preferred Marketing Developer, announced Tuesday the launch of the Marketing Automation tool. A fully integrated module ...

Automation Heroes (@automationhero) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Automation World
Automation World is your link to the why and how of manufacturing automation. The purpose of this group is to connect manufacturing engineers,... ...

Young people don't consider automation issues when choosing a career
... launched a new research study that determines that almost half (49 percent) of young people in Britain are not taking the issue of job automation ...

Robots Will Change World Beyond Recognition Says BoA; Automation Will Change Jobs More Than Kill Them ...
Robot Theory The battle of robot theory is on. Bank of America paints one picture and McKinsey another. Let's investigate both theories. Automation ...

Rockwell Automation Announces Mobility Co-Innovation with Microsoft
A new mobility co-innovation project by Rockwell Automation and Microsoft Corp. will be demonstrated at Automation Fair in Chicago Nov. 18 and ...

3 Growing Digital Trends for 2016: Automation, Personalization, Gamification.
1. Marketing Automation What is it? Marketing automation is a category of technology that allows companies to streamline, automate, and measure ...

Resources last updated: 12/11/2015 12:21:39 AM