Page 1 of 1
How to read settings in Word
Posted: Thu May 04, 2023 2:52 pm
by driessen
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.
Re: How to read settings in Word
Posted: Thu May 04, 2023 3:15 pm
by Antonio Linares
Dear Michel,
from chatGPT 4:
Code: Select all | Expand
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 ?
Re: How to read settings in Word
Posted: Thu May 04, 2023 3:50 pm
by karinha
Re: How to read settings in Word
Posted: Fri May 05, 2023 4:20 am
by Jimmy
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}
Re: How to read settings in Word
Posted: Fri May 05, 2023 8:58 am
by driessen
Thanks a lot for any help.
I have the information I needed.
Re: How to read settings in Word
Posted: Mon Jul 31, 2023 2:17 pm
by driessen
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.
Re: How to read settings in Word
Posted: Mon Jul 31, 2023 2:54 pm
by Antonio Linares
Dear Michel,
How are you finally reading the settings ?
Please post the code to see how to save them, thanks
Re: How to read settings in Word
Posted: Mon Jul 31, 2023 3:30 pm
by driessen
Antonio,
This is the code with the method how I read the startup folder of Word :
Code: Select all | Expand
******************************************************************************
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.
Re: How to read settings in Word
Posted: Tue Aug 01, 2023 5:49 am
by Antonio Linares
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
Re: How to read settings in Word
Posted: Tue Aug 01, 2023 12:12 pm
by driessen
Antonio,
While compiling your example, I get the error : Error E0022 Invalid lvalue ':'
So the settings in Word can't be changed that way.
Re: How to read settings in Word
Posted: Tue Aug 01, 2023 5:51 pm
by Antonio Linares
Dear Michel,
Please try it this way:
cWord:Options:DefaultFilePath[8] = cNewPath
Re: How to read settings in Word
Posted: Tue Aug 01, 2023 5:53 pm
by Antonio Linares
Re: How to read settings in Word
Posted: Tue Aug 08, 2023 11:06 pm
by driessen
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.
Re: How to read settings in Word
Posted: Wed Aug 09, 2023 7:27 am
by Antonio Linares
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 )
Re: How to read settings in Word
Posted: Thu Aug 10, 2023 12:56 pm
by driessen
Antonio,
Once again, thank you very much.
It's working fine.