How to Change Link to Unbound Object using VBA

G

Guest

I need help in changing a linked unbound object to a different link using
VBA code.

The unbound object is really need on a report, but I read from the knowledge
base (KB) that it can only be done in a form and so I embed the form as a
subform in my report. I tried that and it works. What I see in the form is
what I see on the report.

I have an excel file with many worksheet named Card 1, Card 2, etc. On each
of the workseet (Card 1 as example) is one large cell which has tablet
drawings on it.

I copied that cell from the excel worksheet and pasted it into my form as a
link object.

After doing that, I see the following properties set for that unbound object
frame:

Object Name OLEUnbound4
SourceDoc c:\test\template.xls
SourceItem Card 1!Print_Area

I tried the VBA code in the On Open of the form:

With Me![OLEUnbound4]
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLELinked
.Class = "Microsoft Excel 2000"
.SourceDoc = "c:\test\template.xls"
.SourceItem = "Card 1!Print_Area"
.Action = acOLECreateLink
.SizeMode = acOLESizeClip
End With

I tried changing the SourceItem to "Card 2!Print_Area" and I don't see the
image from the second workseet (Card 2). If I manually open the edit menu
and select OLE/DDE Links, and select "Change Source", and put in Card 2 in
the parth there, it updates the Unbound Object to the new workseet (Card 2).

I am using both Access 2000 with excel 2000 and Access 2002 with Excel 2002.
The different in the name of the .Class (one uses "Excel.Sheet" and the
other "Microsoft Excel 2000")

I need help update the link in the form using VBA code.

Thank You,

Gary
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top