Opening a Visio Document

Mr. Wizard

Board Regular
Joined
Sep 28, 2005
Messages
67
I have a Visio Drawing that represents a schedule. Since the information to generate the schedule is in a database, I would like to use Excel to query the database and generate the schedule drawing elements. I have a Visio Stencil that will come up if I use a default drawing as a template, and this will allow me to drop the shapes on the Visio Drawing from the shape master.

I would like to drive Visio from Excel, so the result for the user is one-touch generation of a Visio schedule. I have referenced the Visio Library in Excel VBA Editor. I have tried recording the macro to open a file in Visio and copying it into Excel after I opened an instance of Visio, but I get an error.

It seems like this would be rather straight-forward, but it escapes me so far.

How do I open the specific Visio Drawing file in an instance of Visio driven by the Excel macro?

Here is where I've gone so far...

Public Sub VISO_text()

Dim objVis As New Visio.Application

Set objVis = New Visio.Application
Application.Documents.OpenEx "C:\DefaultSchedule.vsd", visOpenRW
Application.Windows.ItemEx("Drawing1").Activate
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Here is the solution to my problem. As usual, after diligent search, I find a working solution here:

Sub DefaultBarChart()

Dim objVisio As Visio.Application

Set objVisio = CreateObject("Visio.Application")

With objVisio
'.Visible = False
.Documents.OpenEx "C:\DefaultSchedule.vsd", visOpenRW

' other stuff to create & manipulate Visio objects
End With

End Sub
 
Upvote 0
I think it would be more like:

Code:
Public Sub VISO_text() 

Dim objVis As Object
Set objVis = CreateObject("Visio.Application")
objVis.Documents.OpenEx "C:\DefaultSchedule.vsd", visOpenRW 
objVis.Windows.ItemEx("Drawing1").Activate
 
Upvote 0
Thanks,

I will try it out, and see. The code I found as a solution does not work entirely with my drawing, so some revision is in order.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,447
Members
448,966
Latest member
DannyC96

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top