Reference an object in a word document from Access

BigJimSlade

Registered User.
Local time
Today, 09:08
Joined
Oct 11, 2000
Messages
173
Hey, Big Jim here:

I think this one is just a matter of knowing the right object and properties, but I am clueless.

I have a word document with an image on it (img1).

I would like to open the word document (no prob there) and from Access VBA set img1.visible = False.

Any thoughts?

Thanks in advance!

Big Jim
 
In case anyone else finds this interesting, I figured out a way to do it (the key is to use the shape property of a word document):

Private Sub cmdExecute_Click()

Dim w As Word.Application
Dim d As Word.Document
Dim m As MailMerge
Dim mm As MailMergeDataSource
Dim o As Object
Dim shp As Word.Shape
Dim rsta As Recordset

Set rsta = CurrentDb.OpenRecordset("SELECT * FROM
REPORT;")
Do Until rsta.EOF
Set w = New Word.Application
Set d = w.Documents.Open
("D:\Test\Word\Temp_to_merge_image.doc")

'For Each shp In d.Shapes
' If you want to loop through the objects...
'Next shp
If rsta!Good = True Then
Set shp = d.Shapes("Control 4")
Else:
Set shp = d.Shapes("Control 5")
End If
shp.Activate
shp.Delete
Set m = d.MailMerge
Set mm = d.MailMerge.DataSource
mm.QueryString = "SELECT * FROM [Report] WHERE Name
= '" & rsta!Name & "'"
m.Execute
Set mm = Nothing
Set m = Nothing
d.Close wdDoNotSaveChanges
Set d = w.Documents("Form Letters1")
d.SaveAs ("C:\Test" & rsta.AbsolutePosition & ".doc")
d.Close
w.Quit
PauseIta (2)
rsta.MoveNext
Set d = Nothing
Set w = Nothing
Loop





End Sub



Good luck!

Big Jim
 

Users who are viewing this thread

Back
Top Bottom