Option Explicit
Dim VS As Visio.Application
Dim vsd As Visio.Document
Dim vsp As Visio.Pages
Private Sub cmdExit_Click()
frmMain.Visible = False
If TypeName(VS) <> "Nothing" Then
If VS.Visible = True Then
VS.Quit
End If
End If
Set VS = Nothing
Set vsd = Nothing
Unload Me
End Sub
Private Sub cmdRun_Click()
Dim vso As Visio.Application
Dim vsd As Visio.Document
Dim vsp As Visio.Page
Dim shp1Obj As Visio.Shape
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
vsp.Drop shp1Obj, 2, 5.5 'Drop shape on page at position 2, 5.5
shp1Obj.Delete 'Remove original imported reference
Set shp1Obj = vsp.Shapes(1) 'Re-Set object to dropped shape
'Stretch image
shp1Obj.Cells("Width") = 2 'Unit is Inches
shp1Obj.Cells("Height") = 2.5
'Set coordinate system ?
shp1Obj.Cells("BeginX") = 0
shp1Obj.Cells("EndX") = 0
shp1Obj.Cells("BeginY") = 0
shp1Obj.Cells("EndY") = 0
'Info on shape
MsgBox "Width Units: " & shp1Obj.Cells("Width").Units & vbNewLine & _
" Width Row: " & shp1Obj.Cells("Width").Row & vbNewLine & _
" Width Column: " & shp1Obj.Cells("Width").Column
MsgBox "Height Units: " & shp1Obj.Cells("Height").Units & vbNewLine & _
" Height Row: " & shp1Obj.Cells("Height").Row & vbNewLine & _
" Height Column: " & shp1Obj.Cells("Height").Column
MsgBox "Angle Units: " & shp1Obj.Cells("Angle").Units & vbNewLine & _
" Angle Row: " & shp1Obj.Cells("Angle").Row & vbNewLine & _
" Angle Column: " & shp1Obj.Cells("Angle").Column
End Sub