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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation: How to prevent from try to open worddoc which already open

Status
Not open for further replies.

Nifrabar

Programmer
Mar 16, 2003
1,343
NL
Hi

NextQ

I open a worddoc programmaticly.
The doc is automaticly populated with a recod from VFP by pressing a button.
So far so good.

Now it happens that if I press the button again (new record) the Word doc which is already populated with data is getting also dat from new record.

So I like to detect if my worddoc is still open (since 1st button-press).

Any suggestion?

-Bart
 
Bart,

Do you mean that you want to detect if the user has closed the document? Interactively?

If so, check that the document variable still contains an object. For example, if oDoc is the variable:

Code:
IF VARTYPE(oDoc) = "O" AND NOT ISNULL(oDoc)
  * Document still exists
ELSE
  * Document has been closed
ENDIF

If I've misunderstood the question, please clarify.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike,
In fact I now realise that I am looking for the determination if doc has become dirty.
-Bart
 
Bart,

The Saved property will tell you if the document is dirty.

If Saved is True, the document has not changed since it was last saved. If it's False, then there are changes pending.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mike,

Thanks, oWord.ActiveDocument.Saved gives me the status.
In addition to prevent from writing information from several records into a single worddoc I want to save that worddoc prior to provide information from other record.
I looked into getdir() and getfile() functions but both seem only usefull to get information for opening a file.
I'm sure it can but I am missing the 'howto':
Would it be possible to call from VFP the SaveAs method of Word? And afterthat close the doc? I like to give my users the opporunity to give the doc a user-decided name.

-Bart

-Bart
 
Well, just oversaw the putfile() dialog. So problem solved.
 
Bart,

Yes, you can call SaveAs from VFP:

Code:
oWord.ActiveDocument.SaveAs

However, if you want to display the dialogue where the user can specify a filename and path, you need to use Save, not SaveAs.

If the document has not been saved before, Save will open the dialogue.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
You might want to look in the VFP FAQ's

faq184-4140
Function to enumerate running processes.

There is also
faq184-5470
How to determine what application are iconified on the taskbar.

Good Luck,
JRB-Bldr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top