Option Explicit
'Add reference to MS Visio xx.x Object Library
Dim vsO As Visio.Application
Dim vsD As Visio.Document
Dim vsP As Visio.Page
Dim shp1Obj As Visio.Shape
Dim shpGrid1 As Visio.Shape
Private Sub cmdRun_Click()
Set vsO = New Visio.Application
Set vsD = vsO.Documents.Open("D:\Development\VB_Visio\VB.vst")
vsO.Visible = True
Set vsP = vsD.Pages.Item(1)
Set shp1Obj = vsP.Import("D:\Development\work03.gif")
'Show the grid if its a drawing
If vsO.Application.ActiveWindow.Type = visDrawing Then
vsO.Application.ActiveWindow.ShowGrid = True
Else
'Tell the user why you're not showing the grid.
MsgBox "Current window is not a drawing window.", vbOKOnly
End If
'Stretch image
shp1Obj.Cells("Width") = 2 'Unit is Inches
shp1Obj.Cells("Height") = 2.5
'Set coordinates
shp1Obj.Cells("PinX") = 1
shp1Obj.Cells("PinY") = 1
'Link Excel workbook
Set shpGrid1 = vsP.InsertFromFile("D:\Development\VB_Visio\Round Selected Region.xls", visInsertLink)
shpGrid1.Cells("PinX") = 3
shpGrid1.Cells("PinY") = 3
End Sub