Mailing Label via Word com object

Hi All

I am using OLE4GL to provide a Word interface within my Progress 9.1 application. This allows me to open/create a Word document, insert various formatted text into it from my db (in this case a letter including customer name and address) and then save it.

All good so far but now I want to be able to automatically generate/print a mailing label for the customer's address I've just written to the document.

Has anyone used the "Mailing Label" functionality within Word before and/or does anyone know the correct syntax to drive it properly?

Many thanks in advance.
Chris
 
Have you tried recording a macro and looking into the code ?

Just out of interest, anyone using wordml ?
 
No takers ... ?

Simple to use, far more efficient, can run on the server-side ... and so
on. But you'll need a current release, atleast Office 2003.

You can download and install the docs off msdn.com ( for free
ofcourse ).

http://www.microsoft.com/downloads/details.aspx?FamilyId=FE118952-3547-420A-A412-00A2662442D9&displaylang=en

You can start with Schemas \ Word \ Concepts. Personally I found the
explanation short, simple and clear.

But there's no shortage of materials, on the net, to choose from. HTH
 
Good idea, thanks! The macro was great to get the syntax, the trouble is I think I've now hit a brick wall as the commands are rejected with the message 'the document is open in another application'. It's something to do with the OLE imbedding but I'm not sure exactly what it is. Trawling the web seems to point to possibility it may be a limitation of this kind of connection where many features of the embedded application are unavailable. Frustrating, it is....
 
Thanks but I'm not sure that's the issue. It seems that when you embed something like Word, all Word methods are not necessarily available via the com-handle and I think the message I'm getting relates to this. Why on earth this is so is a mystery (Microsoft huh :confused: ) . For example, the method SaveAs works but the method Save does not (returns the same message as I'm getting). Likewise PrintPreview doesn't work but Print does. Unless I can get this sorted soon it's back to good old DDE conversations! They might not be pretty but I can drive every aspect of Word 99% of the time. :o
Thanks for the suggestions and input...
 
Can you post a code snippet ?

Just a sample of what's causing the trouble, usually if it's too cumbersome it scares off some of the people trying to help.
 
Good idea, an abridged version of the code is as follows:

chCtrlFrame:OLE4GL:CreateObject(“Word.Document.8”,FALSE).
chCtrlFrame:OLE4GL:Server().

OleServer = chCtrlFrame:Ole4GL:OleHandle
Application = OleServer:Application
Document = Application:ActiveDocument
Selection = Document:Application:Selection

range_start = Selection:Start().
insertText(customer.address_label).
range_end = Selection:End().
Selection:SetRange(range_start,range_end).
NO-RETURN-VALUE Document:SaveAs ( "TESTFILE" BY-VARIANT-POINTER ).

/* all works so far - from here on though, the following methods return a message saying "document is in use by another application" */

Document:PrintPreview()
Document:Save()
Document:Envelope:Printout()


 
I don't have alot of time right now, I might add a sample tomorrow.

First of why are you using and ActiveX automation object thru a CONTROL-FRAME as you would for an ActiveX control ?

What is OLE4GL ? I've searched a recent copy of the docs, just incase, and came up with nothing.

You can find references in the "Programming Interfaces" doc, "Using COM Objects in the 4GL", "ActiveX Automation Support" and "ActiveX Control Support".

There are samples at %DLC%\src\samples\activex. HTH
 
Do you mean something like:

Code:
DEFINE VARIABLE chWord AS COM-HANDLE.
 
CREATE "Word.application" chWord.
 
chWord:Documents:ADD(,,0). /* create a new empty document */
 
chWord:ActiveDocument:ActiveWindow:Selection:TypeText("Hello world"). /* put in some text */
 
chWord:ActiveDocument:SaveAs("C:\temp\TESTFILE").  /* save the document */
 
chWord:ActiveDocument:Printout(). /* print the document */
 
chWord:QUIT().  /* close word */
RELEASE OBJECT chWord.  /*Cleanup */
ASSIGN chWord = ?.

HTH,

Casper.
 
I forgot to mention but I made an tested this codesample with progress 9.1D06 and office2003....
So I don't know if this works for word v8 which u use in your example. (2003 is word.application.11)

Casper.
 
Back
Top