Instantiating Word 2010 from OpenROAD

233 views
Skip to first unread message

Colin Hay

unread,
May 27, 2012, 8:27:09 PM5/27/12
to openroa...@googlegroups.com

Hello everyone,

 

I’m getting the following errors when trying to invoke Word 2010 to convert the file to PDF via a FreePDF printer

This works fine on one client but not another which makes me think its an environmental issue …

 

E_WT0029 Error at line 5274 of eitreporter_uc.

E_WT006D The invocation of an external object method failed.

    The method 'printout' for source 'Microsoft Word' returned an error code

    of 80020009 and the error message:

     'This method or property is not available because a document window is

    not active.'

 

E_WT0029 Error at line 5275 of eitreporter_uc.

E_WT006D The invocation of an external object method failed.

    The method 'printout' for source 'Microsoft Word' returned an error code

    of 80020009 and the error message:

     'This method or property is not available because a document window is

    not active.'

 

E_WT0029 Error at line 5276 of eitreporter_uc.

E_WT0028 Returning from eitreporter_uc.doc2pdf() due to error.

 

E_WT0030 Cannot find attribute 'activeprinter' for a variable reference.

    The attribute 'activeprinter' was used in a variable reference, but this

    attribute is not defined for the type of the variable to which the

    attribute is being applied. Recompile the code and check the spelling of

    the attribute name.

 

E_WT006D The invocation of an external object method failed.

    The method 'activeprinter' for source 'Microsoft Word' returned an error

    code of 80020009 and the error message:

 'Command failed'

 

eitReporter_uc.CreatePDFOutput: PDF could not be created or loaded.

E_WT0029 Error at line 5274 of eitreporter_uc.

 

 

 

 

METHOD Doc2Pdf

(

    XMLDocument                 = VARCHAR(256) NOT NULL,

    PDFDocument                 = VARCHAR(256) NOT NULL

) =

DECLARE

    WordApp#                    = eitMSWord!Application;     // Microsoft Word Object Library

    lv_psfile                   = VARCHAR(256) NOT NULL;

    lv_old_printer              = VARCHAR(256) NOT NULL;

    FreePDF                     = VARCHAR(256) NOT NULL;

    lv_system                   = VARCHAR(2000) NOT NULL;

ENDDECLARE

{

 

    // This functions prints a Word document on the “FreePDF” printer to postscript

    // and converts it to PDF using FreePDF.exe

 

    lv_psfile = PDFDocument + '.ps';

    lv_old_printer = WordApp#.ActivePrinter;

 

    WordApp#.ActivePrinter = 'FreePDF';

    WordApp#.Documents.Open(XMLDocument, false, true);

line 5274    WordApp#.PrintOut(0, 0, 0, lv_psfile, , , , , , , true);

line 5275    WordApp#.PrintOut(, , 4, , , , , , '0', , false);

line 5276    WordApp#.ActivePrinter = lv_old_printer;

    WordApp#.Quit(false);

    WordApp# = NULL;

 

 



Colin Hay

Senior Database Administrator

Fintechnix

 



Level 5,

66 Clarence Street,

Sydney



coli...@fintechnix.com
Phone: +61 2 8234 8276


 

Sidney Glenn

unread,
May 27, 2012, 8:34:57 PM5/27/12
to openroa...@googlegroups.com
Hi Colin

What is your version of OpenROAD....this could well be a reported bug

Sidney
--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To post to this group, send email to openroa...@googlegroups.com.
To unsubscribe from this group, send email to openroad-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openroad-users?hl=en.

Martin.B...@hse.gsi.gov.uk

unread,
May 28, 2012, 3:50:54 AM5/28/12
to openroa...@googlegroups.com

Colin,

 

We have tried to use AcitveX with OpenROAD in the past and have never managed to get it to work reliably (admittedly this was with v 4.1 and we’ve not tried it since).  We would find the same as you – it works on one machine but not on another identical (clone) machine.

 

The way we generate reports is as follows.  I’m not sure how much mileage you’ll get from this in your case:

 

·         Save information required for report to intermediate file in temporary folder.

·         Process registry to find location of Office executable (winword.exe) & check file actually exists – I have code to do this (provided by another member of this group) if you’re interested

·         Run word and open a pre-existing template, running a macro to process the data file.

·         Process the data file to generate report & print if required, from word.

 

 

Regards,

Martin Bloomfield.
_________________________________________________
Application Developer & Database Administrator
IT Branch
Chemicals Regulation Directorate
Health and Safety Executive

YORK

Email: martin.b...@hse.gsi.gov.uk
Website: www.pesticides.gov.uk   www.hse.gov.uk

P Save a tree... please don't print this e-mail unless you really need to


This email was received from the INTERNET and scanned by the Government Secure Intranet anti-virus service supplied by Cable&Wireless Worldwide in partnership with MessageLabs. (CCTM Certificate Number 2009/09/0052.) In case of problems, please call your organisation’s IT Helpdesk.
Communications via the GSi may be automatically logged, monitored and/or recorded for legal purposes.

--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To post to this group, send email to openroa...@googlegroups.com.
To unsubscribe from this group, send email to openroad-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/openroad-users?hl=en.

*****************************************************************************************************************

Please note : Incoming and outgoing email messages are routinely monitored for compliance with our policy on the use of electronic communications and may be automatically logged, monitored and / or recorded for lawful purposes by the GSI service provider.

 

Interested in Occupational Health and Safety information?

Please visit the HSE website at the following address to keep yourself up to date

 

www.hse.gov.uk

 

*****************************************************************************************************************

 

 


The original of this email was scanned for viruses by the Government Secure Intranet virus scanning service supplied by Cable&Wireless Worldwide in partnership with MessageLabs. (CCTM Certificate Number 2009/09/0052.) On leaving the GSi this email was certified virus free.
Communications via the GSi may be automatically logged, monitored and/or recorded for legal purposes.

Tim Binney

unread,
May 28, 2012, 4:08:05 AM5/28/12
to openroa...@googlegroups.com
Martin,

I use the same methodology here. We're currently moving from Microsoft to LibreOffice (and OR4.1 to 5.1), which takes considerable effort!

Tim.

Tim Binney
Senior IS/IT Analyst
Application Management
Improvement and Customer Service
Stirling Council
Tel: 01786 443110

Please consider the environment before printing this.


>>> <Martin.B...@hse.gsi.gov.uk> 28/05/2012 08:50 >>>
Colin,



We have tried to use AcitveX with OpenROAD in the past and have never
managed to get it to work reliably (admittedly this was with v 4.1 and
we've not tried it since). We would find the same as you - it works on
one machine but not on another identical (clone) machine.



The way we generate reports is as follows. I'm not sure how much
mileage you'll get from this in your case:



* Save information required for report to intermediate file in
temporary folder.

* Process registry to find location of Office executable
(winword.exe) & check file actually exists - I have code to do this
(provided by another member of this group) if you're interested

* Run word and open a pre-existing template, running a macro to
process the data file.

* Process the data file to generate report & print if required,
from word.





Regards,

Martin Bloomfield.
_________________________________________________
Application Developer & Database Administrator
IT Branch
Chemicals Regulation Directorate
Health and Safety Executive
YORK

Email: martin.b...@hse.gsi.gov.uk
<mailto:martin.b...@hse.gsi.gov.uk>
Website: www.pesticides.gov.uk <http://www.pesticides.gov.uk/>
www.hse.gov.uk <http://www.hse.gov.uk/>

P Save a tree... please don't print this e-mail unless you really need
to



From: openroa...@googlegroups.com
[mailto:openroa...@googlegroups.com] On Behalf Of Colin Hay
Sent: Monday, May 28, 2012 1:27 AM
To: openroa...@googlegroups.com
Subject: [openroad-users] Instantiating Word 2010 from OpenROAD



Hello everyone,



I'm getting the following errors when trying to invoke Word 2010 to
convert the file to PDF via a FreePDF printer

This works fine on one client but not another which makes me think its
an environmental issue ...
This email and any attachments are intended solely for the individual or
organisation to which they are addressed and may be confidential and/or legally
privileged. If you have received this email in error please forward it to
servi...@stirling.gov.uk and then delete it. Please check this email and any
attachments for the presence of viruses as Stirling Council accepts no liability for
any harm caused to the addressees' systems or data. Stirling Council may
monitor its email system. Stirling Council accepts no liability for personal emails.

Tulloch, Alex

unread,
May 28, 2012, 4:20:36 AM5/28/12
to openroa...@googlegroups.com
We use word for our company's Invoicing - (one of the 5 companies is
using Crystal - just to make sure I had an alternative).

I use word's mail-merge facility to populate a pre-defined template from
a table in the Database.

This method has worked fine in all versions since office97.

Alex Tulloch.
Analyst Programmer
Aviagen Ltd
': +44 (0) 131 527 8188
*: atul...@aviagen.com
This e-mail contains confidential information and is intended solely for use by the individual named or entity to whom it is addressed. Please notify the sender and postm...@aviagen.com immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the named addressee, you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. Aviagen accepts no liability for the content of this e-mail and any consequences of actions taken in reliance on the contents, unless that information is subsequently confirmed in writing. Any views, opinions or actions presented in this e-mail are solely the author's and have not been approved by Aviagen. Any defamatory statements or infringing communication is contrary to Aviagen policy and outside the scope of the employment of the individual concerned. No employee or agent is authorized to conclude any binding agreement on behalf of Aviagen with another party by e-mail. Aviagen has taken reasonable precautions to ensure no viruses are present in this e-mail, but cannot accept responsibility for any loss or damage arising from the use of this e-mail or attachments.
*****************************************************************************

James Higson

unread,
May 28, 2012, 6:44:07 PM5/28/12
to openroa...@googlegroups.com
Just to put this issue in context, we (Colin, myself and Fintechnix) do not have an issue producing the reports in MSWord format. That part is simple and brilliant (even if I do say so myself). The issue is converting the MSWord document into an immutable and portable format such as PDF. We use FreePDF for this purpose, courtesy of the magnificent Bodo. Usually FreePDF works like a charm, but on a few isolated machines it is very flakey.
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

Bodo Bergmann

unread,
May 29, 2012, 8:42:13 AM5/29/12
to openroa...@googlegroups.com
The error code 0x80020009 just means that there was an exception
The error message:
'This method or property is not available because a document window is
not active.'
suggests, that the document has not been loaded (yet).
As this happens directly after the WordApp#.Documents.Open() method
invocation,
I assume that Open() either takes longer or fails on the few isolated
machines.
Have you tried (for testing purposes) use a sleep (e.g. "sleep 5;")
after the open()?
Have a look at: http://support.microsoft.com/kb/280821/en-us
for information on timing issue.

You could also try to activate the document after it is opened.
The Open() method should return a Document object (check that it isn't
null!),
on which you can invoke the Activate() method.
I have found some articles which describe situations of Open() method
retuning NULL, e.g.
http://social.msdn.microsoft.com/Forums/en/architecturegeneral/thread/0f
5448a7-72ed-4f16-8b87-922b71892e07

HTH.

Best regards,
Bodo.

Joseph C. Kronk

unread,
May 29, 2012, 5:29:15 PM5/29/12
to openroa...@googlegroups.com
Is there a reason why you don't just use word to save the file as a pdf?

James Higson

unread,
May 29, 2012, 6:31:02 PM5/29/12
to openroa...@googlegroups.com
Now we are using Word 2010, that is something I intend to investigate just as soon as I have a spare 5 minutes.

Bodo Bergmann

unread,
May 30, 2012, 12:01:45 PM5/30/12
to openroa...@googlegroups.com
Hi James,

I was of the impression that you are (still) using FreePDF,
because you are using some of its additional features
like putting a stamp or watermark on PDF pages,
Which Word probably doesn't offer.

Exporting as PDF from Word is easy - this should already work with Word
2007.
Example:

// Export Word Document as PDF (17=wdExportFormatPDF)
myDoc.ExportAsFixedFormat('c:\temp\test.pdf', 17, 0, 0, 0, 1, 1, 0, 1,
1, 0, 1, 1, 0);

See http://msdn.microsoft.com/en-us/library/bb256835(v=office.12).aspx
for a reference of the method (and its parameters).

Regards,
Reply all
Reply to author
Forward
0 new messages