|
-
Sep 24th, 2004, 09:30 AM
#1
Thread Starter
Fanatic Member
Positioning in Visio
hi,
i have made an application that will open visio and put some drawings in it, from VB6. it works like i want it too but the only problem is that i can not position the drawings from VB6. i was doing some research and i found the Glueto and GlueToPos methods, and i think that is what i am looking for. but i am unsure of how to use them from VB6 so i was wondering if maybe some one knows how to use them?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 24th, 2004, 11:07 AM
#2
Hey Dubya007, I don't think those are methods you want to be
using to position a shape object. What they do is create a
connection point between two shape objects. Let me bring up my
old example and modify it to position a shape object.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2004, 11:33 AM
#3
Thread Starter
Fanatic Member
okay that sounds good. the reason that i wanted to do that was because i read in the help files that you can glue a shape to a guide line but i haven't been able to do that so i think that i will wait for you. thanx man.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 24th, 2004, 12:29 PM
#4
Ok, here is what I got. If you import a image and set it to a shape
object, I could figure out how to move it. But if you drop another
instance of the imported image shape and delete the original,
you can position the dropped shape within the drop method. May
not be elegant, but it works. 
VB Code:
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
VB/Outlook Guru!
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2004, 12:32 PM
#5
Thread Starter
Fanatic Member
check this out. i was able to move the shape by setting the cells formulas.
i found a way to did it that takes only 2 lines of code. if it is not a good thing to do let me know.
VB Code:
Private Sub cmdVisio_Click()
Dim Xcoordinate As Long
Dim Ycoordinate As Long
Dim shape1 As Visio.Shape
Dim YCell As Visio.Cell
Dim XCell As Visio.Cell
If OpenAlready = True Then
GoTo KeepGoing
End If
'Open the Visio File
Set VisioApplication = New Visio.Application
Set VisioDocument = VisioApplication.Documents.Open("H:\SAMDrawing\SAMDraw\Test.vsd")
OpenAlready = True
VisioApplication.Visible = True
Set VisioPage = VisioDocument.Pages.Item(1)
KeepGoing:
'Getting the coordinates from the user
Xcoordinate = InputBox("Enter the X coordinate for the Drawing", "X Coordinate")
Ycoordinate = InputBox("Enter the Y coordinate for the Drawing", "Y Coordinate")
Debug.Print Xcoordinate
Debug.Print Ycoordinate
Debug.Print FName
'The shape is set so that it is in Visio, then it imports a picture into the
'shape
Set shape1 = VisioPage.Import(FName)
'Setting the coordinates for the picture
Set YCell = shape1.Cells("PinY")
Set XCell = shape1.Cells("Pinx")
'Setting the picture to the coordinates
XCell.Formula = Xcoordinate
YCell.Formula = Ycoordinate
'Kill the File as it is no longer needed and another drawing can be added
Kill (FName)
Debug.Print "Killed " & FName
'The shape is cleared from memory so that another shape can be added.
Set shape1 = Nothing
End Sub
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 24th, 2004, 12:39 PM
#6
Yes, thats better. I thought I tried the PinX and it didnt exist in the
cells collection. Oh remember, I tried "PinPos" and "Pin Pos". Oh
well I figured out how to use the Drop method anyways. Its cool
too. Good job! You may want to use a Double for Xcoordinate
and Ycoordinate.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2004, 12:40 PM
#7
Thread Starter
Fanatic Member
thanx. double would be better?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 24th, 2004, 12:48 PM
#8
Yes, in case someone wants precise positioning with decimal points.
Check out these other property settings.
VB Code:
vsd.Creator = "RobDog888"
vsd.Company = "RobDog888"
vsd.Title = "VB Visio Automation"
vsd.Description = "A Visual Basic automation of Microsoft Visio 2002"
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 24th, 2004, 12:57 PM
#9
Thread Starter
Fanatic Member
didn't think of that but i will change them. thanx for all the help man i have gotten alot of this done because you've helped me on this project.
vsd.Creator = "RobDog888"
vsd.Company = "RobDog888"
vsd.Title = "VB Visio Automation"
vsd.Description = "A Visual Basic automation of Microsoft Visio 2002"
this is put in under the opening of the document right?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 24th, 2004, 01:32 PM
#10
Yes, after opening the document, but you can use your information. 
No prob. I always like a challenge.
VB Code:
vsd.Application.ActiveDocument.Pages(1) = "VB Visio-1" 'Or such
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 27th, 2004, 07:55 AM
#11
Thread Starter
Fanatic Member
yeah it was a challenge. i have been given my new challenge now i have to put a table into the visio doc. and try to fill "cells" values from an excel spreadsheet.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 27th, 2004, 11:12 AM
#12
Maybe it would of been easier to use Excel, given the new addition.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 27th, 2004, 11:36 AM
#13
Thread Starter
Fanatic Member
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 27th, 2004, 11:38 AM
#14
No, was thinking if we had started out using Excel to import
the images into and now that you need an Excel like chart, it
would of been easy. But I dont know all the other aspects of your
program so was just wondering? And never thought about if Visio
could contain an ole object from excel.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 27th, 2004, 11:54 AM
#15
Thread Starter
Fanatic Member
well i was instructed by my boss to make it in visio, why she is stuck on visio i donno, but i was thinking this. fill the values into Excel then copy and paste it as an ole object into the Visio. but it all has to be done with code.(i think that this is possible)
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 27th, 2004, 12:11 PM
#16
Sounds good. Probably make a new thread for it if there are any problems.
Later.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 27th, 2004, 12:24 PM
#17
Thread Starter
Fanatic Member
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|