Jose Carlos was telling us:
Jose Carlos nous racontait que :
How can I detect if a word document is open and if it is open how can
i do modification from MS access with VBA?
Thanks for any suggestion
Jose
Here is a little something to get you going.
This assumes that Word is running. It would not be wise to assume that. See
the VBA help on GetObject/CreateObject for example of error trapping on
this. Of course, if you find that Word is not running, then it is a safe bet
that the document you want is not opened, much of the code below can then be
skipped...
'_______________________________________
Dim appWord As Word.Application
Dim docTarget As Word.Document
Dim i As Long
Const strDocName As String = "Document5"
Set appWord = GetObject(, "Word.Application")
With appWord
For i = 1 To .Documents.Count
If .Documents(i).Name = strDocName Then
Set docTarget = .Documents(i)
Exit For
End If
Next
End With
If docTarget Is Nothing Then
MsgBox "The target document is not opened."
Exit Sub
End If
With docTarget
'Manipulate doc here, example:
.Paragraphs(2).Range.Font.Bold = True
End With
'_______________________________________
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org