Results 1 to 17 of 17

Thread: Positioning in Visio

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780

    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?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    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?

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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:
    1. Option Explicit
    2.  
    3. Dim VS As Visio.Application
    4. Dim vsd As Visio.Document
    5. Dim vsp As Visio.Pages
    6.  
    7. Private Sub cmdExit_Click()
    8.     frmMain.Visible = False
    9.     If TypeName(VS) <> "Nothing" Then
    10.         If VS.Visible = True Then
    11.             VS.Quit
    12.         End If
    13.     End If
    14.     Set VS = Nothing
    15.     Set vsd = Nothing
    16.     Unload Me
    17. End Sub
    18.  
    19. Private Sub cmdRun_Click()
    20.    
    21.     Dim vso As Visio.Application
    22.     Dim vsd As Visio.Document
    23.     Dim vsp As Visio.Page
    24.     Dim shp1Obj As Visio.Shape
    25.    
    26.     Set vso = New Visio.Application
    27.     Set vsd = vso.Documents.Open("D:\Development\VB_Visio\VB.vst")
    28.     vso.Visible = True
    29.     Set vsp = vsd.Pages.Item(1)
    30.     Set shp1Obj = vsp.Import("D:\Development\work03.gif")
    31.    
    32.     'Show the grid if its a drawing
    33.     If vso.Application.ActiveWindow.Type = visDrawing Then
    34.         vso.Application.ActiveWindow.ShowGrid = True
    35.     Else
    36.         'Tell the user why you're not showing the grid.
    37.         MsgBox "Current window is not a drawing window.", vbOKOnly
    38.     End If
    39.    
    40.     vsp.Drop shp1Obj, 2, 5.5 'Drop shape on page at position 2, 5.5
    41.     shp1Obj.Delete 'Remove original imported reference
    42.     Set shp1Obj = vsp.Shapes(1) 'Re-Set object to dropped shape
    43.    
    44.     'Stretch image
    45.     shp1Obj.Cells("Width") = 2 'Unit is Inches
    46.     shp1Obj.Cells("Height") = 2.5
    47.    
    48.     'Set coordinate system ?
    49.     shp1Obj.Cells("BeginX") = 0
    50.     shp1Obj.Cells("EndX") = 0
    51.     shp1Obj.Cells("BeginY") = 0
    52.     shp1Obj.Cells("EndY") = 0
    53.    
    54.     'Info on shape
    55.     MsgBox "Width Units: " & shp1Obj.Cells("Width").Units & vbNewLine & _
    56.     " Width Row: " & shp1Obj.Cells("Width").Row & vbNewLine & _
    57.     " Width Column: " & shp1Obj.Cells("Width").Column
    58.  
    59.     MsgBox "Height Units: " & shp1Obj.Cells("Height").Units & vbNewLine & _
    60.     " Height Row: " & shp1Obj.Cells("Height").Row & vbNewLine & _
    61.     " Height Column: " & shp1Obj.Cells("Height").Column
    62.  
    63.     MsgBox "Angle Units: " & shp1Obj.Cells("Angle").Units & vbNewLine & _
    64.     " Angle Row: " & shp1Obj.Cells("Angle").Row & vbNewLine & _
    65.     " Angle Column: " & shp1Obj.Cells("Angle").Column
    66.    
    67. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    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:
    1. Private Sub cmdVisio_Click()
    2.     Dim Xcoordinate As Long
    3.     Dim Ycoordinate As Long
    4.     Dim shape1 As Visio.Shape
    5.     Dim YCell As Visio.Cell
    6.     Dim XCell As Visio.Cell
    7.    
    8. If OpenAlready = True Then
    9.     GoTo KeepGoing
    10. End If
    11.    
    12.     'Open the Visio File
    13.     Set VisioApplication = New Visio.Application
    14.     Set VisioDocument = VisioApplication.Documents.Open("H:\SAMDrawing\SAMDraw\Test.vsd")
    15.     OpenAlready = True
    16.     VisioApplication.Visible = True
    17.     Set VisioPage = VisioDocument.Pages.Item(1)
    18.    
    19.    
    20. KeepGoing:
    21.     'Getting the coordinates from the user
    22.     Xcoordinate = InputBox("Enter the X coordinate for the Drawing", "X Coordinate")
    23.     Ycoordinate = InputBox("Enter the Y coordinate for the Drawing", "Y Coordinate")
    24.     Debug.Print Xcoordinate
    25.     Debug.Print Ycoordinate
    26.     Debug.Print FName
    27.     'The shape is set so that it is in Visio, then it imports a picture into the
    28.     'shape
    29.     Set shape1 = VisioPage.Import(FName)
    30.     'Setting the coordinates for the picture
    31.     Set YCell = shape1.Cells("PinY")
    32.     Set XCell = shape1.Cells("Pinx")
    33.     'Setting the picture to the coordinates
    34.     XCell.Formula = Xcoordinate
    35.     YCell.Formula = Ycoordinate
    36.     'Kill the File as it is no longer needed and another drawing can be added
    37.     Kill (FName)
    38.     Debug.Print "Killed " & FName
    39.     'The shape is cleared from memory so that another shape can be added.
    40.     Set shape1 = Nothing
    41. 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?

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    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?

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, in case someone wants precise positioning with decimal points.
    Check out these other property settings.

    VB Code:
    1. vsd.Creator = "RobDog888"
    2. vsd.Company = "RobDog888"
    3. vsd.Title = "VB Visio Automation"
    4. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    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?

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, after opening the document, but you can use your information.

    No prob. I always like a challenge.

    VB Code:
    1. 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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  11. #11

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    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?

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    like an ole object?
    "...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?

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    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?

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    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 PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI 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

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok thanx
    "...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
  •  



Click Here to Expand Forum to Full Width