Solved MS Word question

forum.sourcecode (2000-2005) & forum.td.sourcecode (2005-2010)
kclench
United States of America
Posts: 103
Joined: 26 Jun 2017, 23:22
Location: Ventura, CA, USA

MS Word question

Post by kclench » 14 Apr 2006, 18:32

 Posted by:  Karen Clench 

If MS Word is not already open on the desktop my application
successfully launches Word and displays the WORD document.
However When MSWord is already open -
this stmt is true and the message box 'Something went wrong' is display.
If NOT oDocs.Open ( vFileName, vConfirmConversions, vReadOnly,
vAddToRecentFiles, vPasswordDocument, vPasswordTemplate,
vRevert, vWritePasswordDocument,
vWritePasswordTemplate, vFormat, vEncoding, vVisible, oDoc )

Has anyone else had a problem with this situation where Word is Already
open and we need to open another .doc via CTD? I am running WINXP,
CTD2.1, ptf2. Microsoft Word 9.0 Object Library.apl
I have reviewed posts from both the talkto.guptaworldwide newsgroup and
the current newsgroup for posting on this but cannot find this
situation. Thank you in advance for your help.

Code: Select all

!!CB!! 70
Call true.SetBoolean(TRUE)
Call false.SetBoolean(FALSE)
Call vBool.SetBoolean( FALSE )
Call SalActiveXAutoErrorMode( FALSE )
Call vDummy.MakeOptional(  )
If not SalActiveXGetActiveObject(oWordApp,'Word.Application')
     Call oWordApp.Create ( )
Call oWordApp.PropSetVisible ( TRUE )
Call oWordApp.PropGetDocuments ( oDocs )
Call vFileName.SetString( psFile )
Call vConfirmConversions.SetBoolean ( FALSE )
Call vReadOnly.SetBoolean ( FALSE )
Call vAddToRecentFiles.SetBoolean ( FALSE )
Call vPasswordDocument.SetString ( '' )
Call vPasswordTemplate.SetString ( '' )
Call vRevert.SetBoolean ( FALSE )
Call vWritePasswordDocument.SetString ( '' )
Call vWritePasswordTemplate.SetString ( '' )
Call vFormat.SetNumber ( 0, VT_I2 )
Call vEncoding.SetNumber ( 0, VT_I2 )
Call vVisible.SetNumber ( 1, VT_I2 )
! !
If NOT oDocs.Open ( vFileName, vConfirmConversions, vReadOnly,
vAddToRecentFiles, vPasswordDocument, vPasswordTemplate,
                    vRevert, vWritePasswordDocument,
vWritePasswordTemplate, vFormat, vEncoding, vVisible, oDoc )
     Set fbOk = FALSE
     Call SalMessageBox( 'Something went Wrong.',
                 'Application Did Not Launch', MB_Ok )
Else
     Set fbOk = TRUE

Martin Duty

Re: MS Word question

Post by Martin Duty » 14 Apr 2006, 22:33

 Posted by:  Martin Duty 

Hi Karen,

Not sure what the problem is. I do not have 2.1 anymore, but I was able to
make your code work under 4.0PFT1 and Word 10.

I've attached a small test program that works in my enviroment (saved as
text). Do you know how to modify it so you can open it in 2.1? Open in
Notepad, line 9 change the last number (34) to something lower (I don't
remember what 2.1's number is 28?) Save it, now you should be able to open
it.

You will have to remove three extra parameter variants from the oDocs.Open
call (under both buttons) statement I have (since I'm using a newer version
of Office) vOpenAndRepair, vDocumentDirection, vNoEncodingDialog. It then
should work for you.

If you are still having problems, the best solution is for you to create a
small test program that shows your problem. Then someone here I'm sure can
help out.

Martin

You do not have the required permissions to view the files attached to this post.

Martin Duty

Re: MS Word question

Post by Martin Duty » 14 Apr 2006, 22:35

 Posted by:  Martin Duty 

Oh... and change the ActiveX library name to maych yours.

Martin

kclench
United States of America
Posts: 103
Joined: 26 Jun 2017, 23:22
Location: Ventura, CA, USA

Re: MS Word question

Post by kclench » 15 Apr 2006, 02:02

 Posted by:  Karen Clench 

Hi Martin,
I was able to test here with your attached .apt. I found that if a
Word doc is opened via the application then with the application I can
open a 2nd doc. However, if I manually open a Word document prior
neither of the pushbuttons will open their associated documents. Both
fall into the 'something went wrong' dialog box. I tested against Word
version 9 and version 11 (with their appropriate ActiveX library names).
Can you test your sample application with the steps I outlined here
and let me know your results? Thank you for your help.
Karen

Lubos Vnuk

Re: MS Word question

Post by Lubos Vnuk » 16 Apr 2006, 18:31

 Posted by:  Lubos Vnuk 

Hi Karen,

Try replacing
Call oWordApp.Create ( )
by
Call oWordApp.CreateObject("Word.Application")

and be sure to declare oWordApp as Word__Application instead of
Word_Application.

HTH,
Lubos.

Martin Duty

Re: MS Word question

Post by Martin Duty » 17 Apr 2006, 14:23

 Posted by:  Martin Duty 

Karen,

Yes, it does behave in the manner you say. I noticed Lubos posted a
solution. I changed the test program to do it as oWordApp.CreateObject(
"Word.Application") and it now works as you want it.

Martin

kclench
United States of America
Posts: 103
Joined: 26 Jun 2017, 23:22
Location: Ventura, CA, USA

Re: MS Word question

Post by kclench » 17 Apr 2006, 19:52

 Posted by:  Karen Clench 

This works beautifully. You made my day! Thank you.

Return to “td.sourcecode”

Who is online

Users browsing this forum: No registered users and 0 guests