Opening 2 Word-documents from my application - solved

Opening 2 Word-documents from my application - solved

Postby driessen » Sat Apr 22, 2023 8:27 am

Hello,

I want to open 2 Word-documents in my application.

This is the source code I use:
Code: Select all  Expand view
oWord1 := TOleAuto():New("Word.application")
oDoc1 := oWord1:Documents:Open(cFile1)

oWord2 := TOleAuto():New("Word.application")
oDoc2 := oWord2:Documents:Open(cFile2)
When the line starting with oWord2 is executed, this message always appears:

Image

Does anyone know why this message appears?
Is there a solution to avoid this message?

Thank you very much in advance for any help.
Last edited by driessen on Sat Apr 22, 2023 10:55 am, edited 1 time in total.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Opening 2 Word-documents from my application

Postby Antonio Linares » Sat Apr 22, 2023 10:05 am

Dear Michel,

I have asked chatgpt about it:
Open the relevant Microsoft Office application (e.g., Word, Excel).
Click "File" in the top-left corner.
Click "Options" to open the Options dialog box.
Select "Trust Center" from the left-hand menu, then click the "Trust Center Settings" button.
In the Trust Center dialog, click "Macro Settings" in the left-hand menu.
Select "Disable all macros with notification" (if not already selected). This setting will allow you to enable macros on a per-document basis with the "Enable Content" button.
Click "OK" to close the Trust Center dialog, then click "OK" again to close the Options dialog.
Close and reopen the document. You should now see the yellow bar with the "Enable Content" button. Click it to enable macros for this specific document.


Open the relevant Microsoft Office application (e.g., Word, Excel).
Click "File" in the top-left corner.
Click "Options" to open the Options dialog box.
Select "Trust Center" from the left-hand menu, then click the "Trust Center Settings" button.
In the Trust Center dialog, click "Trusted Locations" in the left-hand menu.
Click the "Add new location" button.
Browse to the folder where the document is located, select it, and click "OK."
Make sure the "Subfolders of this location are also trusted" option is checked if you want to trust all subfolders.
Click "OK" to close the Trust Center dialog, then click "OK" again to close the Options dialog.
Close and reopen the document. Macros should now be enabled for documents from the trusted location.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Opening 2 Word-documents from my application - solved

Postby driessen » Sat Apr 22, 2023 10:56 am

Hello Antonio,

Was it as simple as that?
Thank you very much for your help.
Have nice weekend.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Opening 2 Word-documents from my application - solved

Postby nageswaragunupudi » Sun Apr 23, 2023 12:19 pm

driessen wrote:Hello,

I want to open 2 Word-documents in my application.

This is the source code I use:
Code: Select all  Expand view
oWord1 := TOleAuto():New("Word.application")
oDoc1 := oWord1:Documents:Open(cFile1)

oWord2 := TOleAuto():New("Word.application")
oDoc2 := oWord2:Documents:Open(cFile2)
When the line starting with oWord2 is executed, this message always appears:

Image

Does anyone know why this message appears?
Is there a solution to avoid this message?
Thank you very much in advance for any help.


Please use FWH WinWordObj() function
Code: Select all  Expand view
oWord  := WinWordObj()
oDoc1 := oWord:Documents:Open( cFile1 )
oDoc2 := oWord:Documents:Open( cFile2 )
 


Even if you call WinWordObj() again and again nothing happens
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Opening 2 Word-documents from my application - solved

Postby Jimmy » Sun Apr 23, 2023 1:27 pm

hi,

Word or Excel are MDI Apps so you can open a 2nd Document / Sheet in new Child Window and don´t need a new Instance
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Opening 2 Word-documents from my application - solved

Postby driessen » Sun Apr 23, 2023 2:37 pm

Guys,

Thank you so much to you both for your help.

WinWordObj() and ExcelObj() are 2 function I didn't know they exist.
Is there also such a function for Outlook?
OutlookObj() isn't working.

Thanks again.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Opening 2 Word-documents from my application - solved

Postby Jimmy » Sun Apr 23, 2023 3:20 pm

hi,

WinWordObj() and ExcelObj() are in c:\fwh\source\function\olefuncs.prg
but they both pint to FWGetOleObject ( in same PRG )

so you can write
Code: Select all  Expand view
Function OutlookObj(); return FWGetOleObject( "Outlook.Application",   @lOutlook  )
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1585
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Opening 2 Word-documents from my application - solved

Postby driessen » Sun Apr 23, 2023 3:51 pm

Thanks a lot for your help.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 92 guests