|
-
Aug 7th, 2001, 02:04 AM
#1
Thread Starter
Conquistador
Enumerating thru all Word Docs using GetObject?
Can i do this, or how can i list all the open word documents (apps) and then allow the user to choose a word document which he wants to insert to, then gain control of that instance of word using GetObject?
-
Aug 7th, 2001, 11:01 AM
#2
Fanatic Member
Create a form and place a commandbutton and listbox on it. Add the follwing. Make sure to reference Word 8 or 9.
Dim wo As Word.Application
Dim wds As Word.Documents
Dim wd As Word.Document
Private Sub Command1_Click()
' list all open documents
On Error Resume Next
Set wo = GetObject(, "Word.Application")
If CStr(wo.Documents.Count) <> 0 Then
Set wds = wo.Documents
For Each wd In wds
List1.AddItem wd.FullName
Next
Else
MsgBox "No documents open"
End If
End Sub
Private Sub Form_UnLoad(Cancel As Integer)
Set wo = Nothing
Set wds = Nothing
Set wd = Nothing
End Sub
Private Sub List1_Click()
Dim wws As Word.Windows
Dim ww As Word.Window
Set wws = Word.Windows
For Each ww In wws
If ww.Document.FullName = List1.List(List1.ListIndex) Then
ww.WindowState = wdWindowStateMaximize
End If
Next
Set wws = Nothing
Set ww = Nothing
End Sub
--------------
HTH
John
-
Aug 7th, 2001, 11:14 AM
#3
Fanatic Member
Put ww.Visible = True after ww.WindowState = wdWindowStateMaximize to show it.
And the reason I used one object to load the documents and another to make visible is because I couldn't figure out a way to make the objects in the commanbutton event work with WindowState.
If you do, let me know.
[email protected]
Thanks,
John
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|