By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,217 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

How to get the full path of a Word document

P: 2
I've spent two days on google trying to find a suitable solution for getting the full path of the running process but in vain.

My question is very simple.

I want to know the full path of the running Word instances. for example if I've 2 instances of Word running currently, I need to know the full path name including drives and directories.I can get the base exe file but not the full path i.e., I can easily get the C:\Program Files\Microsoft Office\office\Winword.exe path but not some thing like "c:\Docs\abc.doc" through vb6.

Is there anyway to get the full qualified path from the list of running process?
Nov 20 '07 #1
Share this Question
Share on Google+
2 Replies

Expert 5K+
P: 8,127
Actually we iddentify the file from its path name. But i am not sure how to get path name from file without knowing the path actually.
Nov 20 '07 #2

P: 112

if i understand you sure you cant get path for opened DOC File as "C:\Doc\MyDoc.Doc" because this is not the process itself it just file opened by Micorosft Word Application, but the process actually is Word.exe, but you have another solution by using Word.Application Object, i tried it and it work good and i got the full path, you can take your direction from here

Expand|Select|Wrap|Line Numbers
  2. Private Sub Command1_Click()
  3. Dim WordObject As Word.Application
  4. Dim CurrentDocument As Integer
  5. Set WordObject = GetObject(, "Word.Application")
  6. If (WordObject Is Nothing) Then MsgBox "Word.exe Is not Running": Exit Sub
  7. For CurrentDocument = 1 To (WordObject.Documents.Count)
  8. MsgBox WordObject.Documents.Item(CurrentDocument).Path & "\" & WordObject.Documents.Item(CurrentDocument).Name
  9. Next
  10. Set WordObject = Nothing
  11. End Sub
if just example show path for all opened documents, and sorry for site moderators , i dont know this code is out of rules or not, it just example for using Word.Application but not the task

Best Regards
Nov 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.