VBA Access Code to open Visio Drawings and Excel charts in Outbound Object Frames

RichBLACKIII

New member
Local time
Today, 05:48
Joined
Aug 5, 2010
Messages
5
VBA Access Code to open Visio Drawings and Excel charts in Unbound Object Frames

I need some help with a bit of Access VBA Code. I have a form with various buttons I want to open different Visio Drawings I created previously into a Unbound Object Frame. I need the code to clear the contents currently in the Object Frame then insert my designated Visio Drawing. The Visio Drawings are currently linked to my Access Tables via OBDC if that makes a difference.

I also have another unbound object frame, that I need to open a excel chart too. Pretty much the same process however just using Excel instead of Visio.

I just need it to happen, through the click command of my buttons. Thanks for your help, you will be contributing to something very important in my business world !! :rolleyes:
 
Last edited:
Welcome to the Forum,

I have just created the following code to open a test visio document and it works. I would hope you can adapt this to either go into your unbound object or direct to Visio.

You will have to Open the VBA Screen (Alt & F11 on the keyboard), then insert a new module, from the insert menu.

Then you have to set the references to Visio from the Tools Menu and References, look down the list until you find microsoft visio 11 object library and tick the box.

Then copy and paste this code into the module. You will have to adjust the file name and possibly the path to your visio documents.

You can then do the same sort of thing for Excel

Function openvis()
Dim vis As Visio.Application
Set vis = CreateObject("Visio.Application")
With vis
.Visible = True
.Documents.Open CurrentProject.Path & "\test me out.vsd"
End With

End Function
 
Thanks for your help. I was able to get your code to work on my form. However I am having a problem embedding the Visio Drawing into the unbound object form....Here is the code I am using

Public Sub EmbedExisting_Click()
Dim ctl As Control
Set ctl = OLEUnbound27
With vis
.Visible = True
.Enabled = True
.Locked = False
.OLETypeAllowed = acOLEEmbedded
.Class = "Visio.vsd"
.SourceDoc = "C:\Documents and Settings\WyattT\My Documents\CommodityDrawings\StyreneButadiene.vsd"
.Action = acOLECreateEmbed
End With
End Sub


I am getting Runtime error '424' object required on the "Set ctl =" part ??
 
Code:
[FONT=Consolas][SIZE=3]With vis[/SIZE][/FONT]

You haven't declared the vis part?
 
Yes, that proably would have been the next problem. But the problem I described still remains. I think I need the correct syntax to actually enter something into my Unbound object frame which is named in the "OleUnbound27" part of the code which that Unbound frame is already on my form.
 
I happend to stumble upon the answer.........You must be in Form View in your database and actually Call the Unbound Object from your database. I found the location of the frame in the references section. Thanks.

Public Sub EmbedExisting_Click()
Dim ctl As Control
Set ctl = Form_CommodityApplication.OLEUnbound27
With ctl
.Visible = True
' Enable control.
.Enabled = True
' Set Locked property to False.
.Locked = False
' Allow embedded objects only.
.OLETypeAllowed = acOLEEmbedded
' Specify the OLE server and the type of object.
.Class = "Visio.Drawing.11"
' Specify the file to be embedded.
.SourceDoc = "C:\Documents and Settings\WyattT\My Documents\CommodityDrawings\StyreneButadiene.vsd"
' Create the embedded object.
.Action = acOLECreateEmbed
End With
End Sub
 
I'm pleased it's working for you.

Well done
 

Users who are viewing this thread

Back
Top Bottom