Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My Excel VBA code checks to see if a specific word file is open.
If I have more than one inistance of Word open, my code only "sees" on instance. How can I loop through all the instances of Word that are open to find the specific document I want to act on? ================================================== === Private Sub cmdOpenPRRRDoc_Click() Dim WordApp As Object Dim fNameAndPath As String Dim doc As Variant, x As Integer On Error Resume Next fNameAndPath = GetPRRRFileName ' CHECK TO DETERMINE IF THE FILE IS ALREADY OPEN ' IF NOT OPEN - THEN OPEN IT If Not FileLocked(fNameAndPath) Then Set WordApp = CreateObject("Word.Application") WordApp.Documents.Open (fNameAndPath) WordApp.Visible = True Set WordApp = Nothing Exit Sub End If ' IF OPEN - THEN ACTIVATE IT For Each doc In Documents If InStr(1, fNameAndPath, doc.Name, vbTextCompare) 0 Then doc.Activate End If Next ' IF MORE THAN ONE INSTANCE OF WORD IS OPEN, I MAY MISS THE FILE IN MY FOR-EACH LOOP End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Extracting specific data from inconsistant multiple word documents | Excel Discussion (Misc queries) | |||
Can only open Read-Only Word documents from Excel using VBA | Excel Programming | |||
Possible to open word documents in Excel using hyperlinks? | New Users to Excel | |||
how do you get Word to open documents in it's own window(s)? | Excel Discussion (Misc queries) | |||
Can't open excel or word documents (says insert sm bus cd?) | Excel Discussion (Misc queries) |