How to read settings in Word

How to read settings in Word

Postby driessen » Thu May 04, 2023 2:52 pm

Hello,

How can I read a setting of Word in my FWH application?

I need to know the startup-folder of Word?
And if someone knows how, also the startup-folder of Excel or Outlook.

Thank you very much for any help.
Regards,

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

Re: How to read settings in Word

Postby Antonio Linares » Thu May 04, 2023 3:15 pm

Dear Michel,

from chatGPT 4:
Code: Select all  Expand view  RUN
LOCAL oWord, cStartupPath
oWord = CREATEOBJECT("Word.Application")
cStartupPath = oWord.Options.DefaultFilePath(10) && 10 is wdStartupPath
? "Word Startup Folder:", cStartupPath
oWord.Quit


what specific setting are you looking for ?
regards, saludos

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

Re: How to read settings in Word

Postby karinha » Thu May 04, 2023 3:50 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7831
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: How to read settings in Word

Postby Jimmy » Fri May 05, 2023 4:20 am

hi,
driessen wrote:I need to know the startup-folder of Word?
And if someone knows how, also the startup-folder of Excel or Outlook.

do you mean which "Start" Folder when User want to "open" a Document or Sheet ?

as it is a Microsoft Product it will use Windows default Folder "Personal Files\Document"
... but File-Dialog Control "might" show you "last Folder"

---

under Xbase++ i have use a "Trick" to show "right" Folder

before call ActiveX i call File-Dialog Control "invisible" to set new Path and than close it
to use a "invisible" Control "just" set Position "outside" Screen e.g. {-1000, -1000}
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: How to read settings in Word

Postby driessen » Fri May 05, 2023 8:58 am

Thanks a lot for any help.

I have the information I needed.
Regards,

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

Re: How to read settings in Word

Postby driessen » Mon Jul 31, 2023 2:17 pm

Hello,

I know now how to read settings in Word.

But can anyone help me in changing the settings in Word?

I also need to know how to put the startup setting in Word back to its default value?

Thank you.
Regards,

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

Re: How to read settings in Word

Postby Antonio Linares » Mon Jul 31, 2023 2:54 pm

Dear Michel,

How are you finally reading the settings ?

Please post the code to see how to save them, thanks
regards, saludos

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

Re: How to read settings in Word

Postby driessen » Mon Jul 31, 2023 3:30 pm

Antonio,

This is the code with the method how I read the startup folder of Word :
Code: Select all  Expand view  RUN
******************************************************************************

LOCAL cStartupPath := ""

PRIVATE cWord

WordOle()

cStartupPath := cWord:Options:DefaultFilePath(8) // 8 is wdStartupPath

* CStartupPath contains the startup folder of Word.
* Standard it is : %USERPROFILE%\AppData\Roaming\Microsoft\Word\STARTUP
*                       but it might be changed for external reasons.

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

PROCEDURE WordOle

*  This procedure builds the OLE-connection with Word

   IF (cWord := WinWordObj()) = NIL
      MsgAlert("Microsoft Word wasn't installed on this computer","Alert")
   ENDIF

RETURN

******************************************************************************
I want to change the startup folder of Word from my FWH-application.

Thanks.
Regards,

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

Re: How to read settings in Word

Postby Antonio Linares » Tue Aug 01, 2023 5:49 am

Dear Michel,

Please try this:

cWord:Options:DefaultFilePath(8) = cNewPath
MsgInfo( cWord:Options:DefaultFilePath(8) )

and check if it works and changes the path or generates an error
regards, saludos

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

Re: How to read settings in Word

Postby driessen » Tue Aug 01, 2023 12:12 pm

Antonio,

While compiling your example, I get the error : Error E0022 Invalid lvalue ':'

So the settings in Word can't be changed that way.
Regards,

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

Re: How to read settings in Word

Postby Antonio Linares » Tue Aug 01, 2023 5:51 pm

Dear Michel,

Please try it this way:

cWord:Options:DefaultFilePath[8] = cNewPath
regards, saludos

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

Re: How to read settings in Word

Postby Antonio Linares » Tue Aug 01, 2023 5:53 pm

Dear Michel,

Please review this:
https://learn.microsoft.com/en-us/office/vba/api/word.options.defaultfilepath
https://documentation.help/VBAWD10/woproDefaultFilePath.htm

It should work as the first try but Harbour syntax does not allows it
regards, saludos

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

Re: How to read settings in Word

Postby driessen » Tue Aug 08, 2023 11:06 pm

Antonio,

I'm sorry, I wasn't able to solve my last problem yet, but I have a new question.

I need to read in my Fwh-application the exact position where my cursor is in a Word-document.
Later on I have to put the cursor back in its original position.

How can I do this?

Thx.
Regards,

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

Re: How to read settings in Word

Postby Antonio Linares » Wed Aug 09, 2023 7:27 am

Dear Michel,

To save the current current position:

nStartPosition = oWordApp:Selection:Range:Start
nEndPosition = oWordApp:Selection:Range:End

To later restore the cursor position:
oWordApp:Selection:SetRange( nStartPosition, nEndPosition )
regards, saludos

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

Re: How to read settings in Word

Postby driessen » Thu Aug 10, 2023 12:56 pm

Antonio,

Once again, thank you very much.
It's working fine.
Regards,

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 73 guests