Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message box in Word via OLE

Status
Not open for further replies.

clegg

Programmer
Jan 25, 2001
98
GB
Hiya everyone!

I'm trying to convert some macros that I created to mailmerge stuff etc. Basically the COBOL program creates the data and then calls MS Word (macro stored in normal.dot).

I've had a few stability problems so thought I'd have a stab at converting it to OLE so I can have greater control in my COBOL program.

Its going OK but my problem is how do I display a message box now in Word. In the macro its just msgbox "whatever", but is this VB(A) code rather than something i can OLE via COBOL.

Your help would be appreciated.

Many thanks

Clegg
 
I'm not sure why you need to do the msgbox in Word? You must have a need in the COBOL to pop up a message box, so just do it in the COBOL directly as you would if you were doing it in VBA.

Glenn

PS - Information about your compiler and environment would be helpful in providing detailed answers to your question.
 
Its just to remind the user to save the record by pressing the save icon on the toolbar (rather than doing a file, save as and putting it in the wrong place!!)

I suppose I could do it in the COBOL app before I call Word but I'd rather make things appear unchanged (you know what users are like!)

Compiler is MF NetExpress 3.0 on Windows.

Cheers

Clegg
 
I'm still not sure I understand exactly what you're doing and the following may be way off the mark. If so, point me in the right direction.

You're not exactly calling Word. You're instantiating a Word object, setting its properties, and invoking its methods in your COBOL program, right? Things like create/open the source document, set the merge data file name, do the merge, etc?

At the point in that string of method calls and property setting where you would like to remind them to save the file, issue the message box in your COBOL code. Or better yet, simply invoke the save method on your Word object and avoid the issue altogether.

Again, if I've misunderstood what you're doing or trying to do, my apologies.

Glenn
 
My apologies if i'm coming across as confusing!

You are correct in the following:
"You're instantiating a Word object, setting its properties, and invoking its methods in your COBOL program, right? Things like create/open the source document, set the merge data file name, do the merge, etc? "

The message box is for when the user creates a letter with the merge fields on it (to be merged at a later date).

Clegg
 
I don't have access to full documentation on the Word object model here, but see the Form_QueryUnload callback (event) procedure. In that procedure, you can check to see if the file has been saved and what its current name is. If it has been saved and it has been named what you think it should be, then exit cleanly. Otherwise, pop your message box up. Depending on the user's response, abort the exit to give the user another chance to save the document, or get out with the document not saved and hence unavailable for merge.

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top