Can anyone help with this please?

I my VB.NET app to list each of the documents that are currently open in Microsoft Word. If any docs are not saved then I need to save them. I have tried using the Word application object but creating a new App object doesn't enable me to see existing Word documents that are already open.

I have been trying to use GetProcessByID but once I have identified the process I am unable to perform simple tasks with the process such as SaveAs or iterate through Word's Documents collection and list the names of each document. Any ideas? please?

I am using Word 2007.

I reckoned that it really wouldn't be so difficult but this problem is really causing me a lot of trouble.

Recommended Answers

All 5 Replies

The Document object has a Saved property. If that is true, there are no changes to be saved.

If doc.Saved <> true Then
   ...
End If

Thank you for replying so promptly - although unfortunately you have not quite grasped the problem.

Yes the Word document object does have a Saved property but the difficulty is that I cannot get at it. I have no reference to an already opened Word application object nor its Documents collection.

Code such as

Dim appWord as Word.Appliction
appWord = New Word.Application


does not let see documents that are currently open in Word but simply starts a new instance of Word.

Does anyone have any experience with using GetProcessByID or something similar? If so how do I assign my appWord object to a process that is already running? Any ideas please?

Unfortunately www.bigresource doesn't have the answer either.

Does anyone know whether I can use a Process in VB.NET and somehow cast it as a Word app object? I have tried to use CreateObjRef but I don't have a sufficient understanding of this function to use it properly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.