Page 1 of 2 12 LastLast
Results 1 to 40 of 75

Thread: Visio and VB6

  1. #1

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

    Visio and VB6

    does any one know if it is possible to connect to Visio with VB6?
    "...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
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109
    A) To do what?

    B) Which version of Visio? (there are two major ones)

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, add the reference to your vb project, create an instance of visio
    and do some automation etc.
    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

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Here is one way of doing it:
    set references to Visio xxxx Type Library and run this sample code:
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim vso As Visio.Application
    3.  
    4.     Set vso = New Visio.Application
    5.     vso.Documents.Open "c:\temp\Test.vsd"
    6.     vso.Visible = True
    7.     Set vso = Nothing
    8.  
    9. End Sub

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    Rob,
    I didn't mean to cross post.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    No prob. Don't hear that too often.
    Thanks!

    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
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I found one of my old projects on Visio. It shows how to set the
    document properties through code as well as a few other things.

    VB Code:
    1. Option Explicit
    2.  
    3. Dim VS As Visio.Application
    4. Dim VSD As Visio.Document
    5.  
    6. Dim lPID As Long
    7.  
    8. Private Sub cmdExit_Click()
    9.     frmMain.Visible = False
    10.     If TypeName(VS) <> "Nothing" Then
    11.         If VS.Visible = True Then
    12.             VS.Quit
    13.         End If
    14.     End If
    15.     Set VS = Nothing
    16.     Set VSD = Nothing
    17.     Unload Me
    18. End Sub
    19.  
    20. Private Sub cmdRun_Click()
    21.  
    22.     Set VS = New Visio.Application
    23.     VS.Visible = True
    24.     lPID = VS.ProcessID
    25.     Set VSD = VS.Documents.Add(App.Path & "\VB.vst")
    26.     VSD.Creator = "RobDog888"
    27.     VSD.Company = "RobDog888"
    28.     VSD.Title = "VB Visio Automation"
    29.     VSD.Description = "Visual Basic automation of Microsoft Visio 2002"
    30.     VSD.PrintLandscape = -1
    31.     VSD.Application.ActiveDocument.Pages(1) = "VB Visio-1"
    32.  
    33. End Sub
    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

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok so it is possible to connect to Visio and make a VB6 application. this is what i am trying to do, i need to know if it is possible to make a VB6 application that will access a Visio file and it will look for certain drawing numbers and put them into the visio file, but it has to be done through VB6.
    "...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?

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    i was looking in my references and i don't see the Visio library. if i don't have it do you know where i can get it?
    "...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
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132
    It has to be installed on your development machine at least.
    Although, I would check EULA for VISIO runtime files distribution procedure.

  11. #11
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Originally posted by RhinoBull
    It has to be installed on your development machine at least.
    Although, I would check EULA for VISIO runtime files distribution procedure.
    There are no redistributable visio runtimes. If you create an application that automates Visio, then the user's machine will have to have a licensed copy of Visio installed on it. There is no legal way around this ...

    That said, I think that Microsoft might have some special integration licensing programs available for Visio, but I am almost certain that they wont be run time royalty free ... and I am certain that the standard Visio EULA has no provisions that allow redistribution.

  12. #12
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Originally posted by Dubya007
    ok so it is possible to connect to Visio and make a VB6 application. this is what i am trying to do, i need to know if it is possible to make a VB6 application that will access a Visio file and it will look for certain drawing numbers and put them into the visio file, but it has to be done through VB6.
    This is all very much do-able. Take a stab at it and post the Visio and VB6 file and I can try to help if you want ...

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok thanx all. Muddy i will maybe have some thing some time later, just researching the possibilities right now.
    "...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
    Originally posted by Dubya007
    ...make a VB6 application that will access a Visio file and it will look
    for certain drawing numbers and put them into the visio file, but
    it has to be done through VB6.
    Look at my code, it opens a drawing and
    changes the page name. Instead of changing the name you could
    check if it matches the page name in question and go from there.
    Is that what you need?

    VB Code:
    1. VSD.Application.ActiveDocument.Pages(1) = "VB Visio-1"
    2. 'Change to something like this...
    3. If VSD.Application.ActiveDocument.Pages(1) = "TheDrawingNameIamLookingFor" Then
    4.     'Do something
    5. Else
    6.     'Do domething else
    7. Endif
    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
    kinda, i need to have a bunch of drawings on an sql server(is that possible?) and then be able to input a part number and it will bring up the drawings and put them all into a visio template.
    but that all depends on if you can put a picture on an SQL server.
    "...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
    Yes, you can put a picture in a field of a record in SQL Server. I havent
    done it, but I know its been asked here before. Try a search.
    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
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Originally posted by RobDog888
    Yes, you can put a picture in a field of a record in SQL Server. I havent
    done it, but I know its been asked here before. Try a search.
    Beacon has a good tutorial regarding this. Download the attachment on the first post of the following thread:

    http://www.vbforums.com/showthread.p...threadid=81916

    For some reason, storing pictures in a database seems to be a controversial subject. I've seen a few heated threads making arguments against it, but I've never seen a good argument brought against the concept IMHO. I say go for it if it makes sense to you ... :-)

  18. #18
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Muddy, I have seen those arguments also. They mainly center
    around placing pictures in an Access database and not a SQL
    Server. Access can do it but it is not scalable for many pictures.
    Also if Access gets corrupt then you loose you pictures. SQL
    Server does not get corrupt.


    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

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    i am at work and can not follow the link, so is there any way that you could show me the whole address of the link, i tried to copy and paste it but it doesn't work?
    Robdogg you seem to know a lot about this stuff, is there a specific format i.e. jpg, tif, gif, bmp, that is better to be stored on an SQL server?
    "...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?

  20. #20
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I would think the better format would be jpg or jpeg.

    Code:
    http://www.vbforums.com/showthread.php?s=&threadid=81916
    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

  21. #21

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok so now i can load a picture on to the SQL server how do i load the images into a picture box?
    "...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?

  22. #22
    PowerPoster
    Join Date
    Feb 2001
    Location
    Crossroads
    Posts
    3,046
    Originally posted by Dubya007
    ok so now i can load a picture on to the SQL server how do i load the images into a picture box?
    Doesnt Beacon's tutorial example do that too?

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    Beacons tutorial example doesn't show how to load pictures into the SQL Server. i found how to do load it into the SQL server some some place else. but it seems to be the same. here is the code.
    VB Code:
    1. Private Sub Command1_Click()
    2. Dim mystream As ADODB.Stream
    3. Set mystream = New ADODB.Stream
    4. mystream.Type = adTypeBinary
    5. mystream.Open
    6. mystream.LoadFromFile "H:\SAMDrawing\MountingW2Nameplates.bmp"
    7. With Rs
    8.     .AddNew
    9.     !ArresterNumber = Text1.Text
    10.     !Drawing = mystream.Read
    11.     .Update
    12. End With
    13. MsgBox "UPDATED AND WORKED"
    14. mystream.Close
    15. Set mystream = Nothing
    16. End Sub
    that is how i have found to save a picture to an SQL server. the only problem is now i donno how to load the picture that is saved there to a an image box, or picture box in VB6. any ideas?
    "...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?

  24. #24

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok i have the part done where i can save/retrieve images from the SQL server and i am working on the VB6 part to open Visio, i just need to be able to put the drawings in specific places in the Visio file. is it possible to put like a "Bookmark" into Visio?
    "...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?

  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I believe there is a way to position them, but not sure about bookmarks.
    Let me look into it.
    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

  26. #26

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok i will look into it as well. i think that it has to do with the different positions from the margins, i saw some thing to that effect in the help files.
    "...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?

  27. #27
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    How about using the .Drop method?
    VB Code:
    1. Example for Drop, Group
    2. 'This Microsoft Visual Basic for Applications (VBA) macro
    3. 'demonstrates dropping shapes using the Page, Document,
    4. 'and Shape objects.
    5.  
    6. Public Sub Drop_Example ()
    7.  
    8.     Dim shp1Obj As Visio.Shape
    9.     Dim shp2Obj As Visio.Shape
    10.     Dim shp3Obj As Visio.Shape
    11.     Dim mstObj As Visio.Master
    12.  
    13.     Set shp1Obj = ActivePage.DrawRectangle(1, 2, 2, 1)
    14.     Set shp2Obj = ActivePage.DrawRectangle(1, 4, 2, 3)
    15.  
    16.     'Example of Page.Drop
    17.     ActivePage.Drop shp1Obj, 3.5, 3.5
    18.     Set shp3Obj = ActivePage.Shapes(3)
    19.  
    20.     'Example of Document.Drop - Creates a master
    21.     Set mstObj = ActiveDocument.Drop(shp3Obj, 0, 0)
    22.  
    23.     'Example of Shape.Drop
    24.     ActiveWindow.DeselectAll
    25.     ActiveWindow.Select shp1Obj, visSelect
    26.     ActiveWindow.Select shp2Obj, visSelect
    27.     ActiveWindow.Group
    28.     Set shp1Obj = ActivePage.Shapes(2)
    29.     shp1Obj.Drop shp3Obj, 3, 3
    30.  
    31. End Sub
    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

  28. #28
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Or the .Import method looks good too.
    Import method
    Example

    Imports a file into the application.

    Version added: 3.0

    Syntax:
    objRet = object.Import(fileName)

    objRet
    A Shape object that represents the new shape imported from the file.

    object
    Required. An expression that returns the Page, Master, or Shape
    object to receive the new shape.

    fileName
    Required String. The name of the file to import; must be a fully
    qualified path.

    Remarks:

    The Import method imports the file specified by fileName onto a
    page, or into a master or group.

    The file extension indicates which import filter to use. If the filter
    is not installed, the Import method returns an error. The Import
    method uses the default preference settings for the specified
    filter and does not prompt the user for non-default arguments.
    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

  29. #29
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Or even use the .PasteSpecial method.
    PasteSpecial method

    Inserts the contents of the Clipboard, allowing you to control the
    format of the pasted information and (optionally) establish a link
    to the source file (for example, a Microsoft Word document).

    Version added: 2002

    Syntax
    object.PasteSpecial (format [,link][,displayAsIcon])

    object
    Required. An expression that returns a Master, Page, or Shape object.

    format
    Required Long. The internal Clipboard format.

    link
    Optional Variant. True to establish a link to the source of the
    pasted data; otherwise, False (the default). Ignored if the source
    data is not suitable for, or doesn't support, linking.

    displayAsIcon
    Optional Variant. True to display the pasted data as an icon;
    otherwise, False (the default).

    Remarks

    To simply paste the contents of the Clipboard into an object, use
    the Paste method.

    The PasteSpecial method of a Shape object works only with
    Shape objects that are group shapes. Use the Type property of a
    shape to determine whether it is a group.

    The value of the format argument can be any of the following:

    A value from VisPasteSpecialFormat (see the following table).
    Any of the standard Clipboard formats, for example, CF_TEXT. For
    details, see the Microsoft Platform SDK on the Microsoft Developer
    Network (MSDN) Web site.
    Any value returned from a call to the RegisterClipboardFormat
    function. For details, see the Microsoft Platform SDK on the MSDN
    Web site.
    Possible values for format declared by the Visio type library in
    VisPasteSpecialFormat are described in the following table.

    Flag
    Value

    visPasteText
    1

    visPasteBitmap
    2

    visPasteMetafilePicture
    3

    visPasteOEMText
    7

    visPasteDeviceIndependentBitmap
    8

    visPasteEnhancedMetafile
    14

    visPasteOleObject
    65536

    visPasteRTF
    65537

    visPasteHyperlink
    65538

    visPasteURL
    65539
    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

  30. #30

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    so if a am using ADO to copy files to the c:\temp file then shouldn't i just load those pictures into the Visio Document?
    "...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?

  31. #31
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Yes, the .Import method looks best. You can get the Shape reference
    after you import one so you can make adjustments to it or ???
    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

  32. #32

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok so i would put this code in the VB6 code window right?

    VB Code:
    1. 'Fname is a variable for the string of the location of a file
    2. Dim shp1Obj As Visio.Shape
    3.  
    4. Set shp1Obj = ActivePage.Import(FName)

    i think that is what i need correct?
    "...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?

  33. #33
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Looks right. Does it work for you though?
    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

  34. #34

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    no sir. here is my code
    VB Code:
    1. Private Sub cmdVisio_Click()
    2. Dim vso As Visio.Application
    3. Dim shp1Obj As Visio.Shape
    4.  
    5.     Set vso = New Visio.Application
    6.     vso.Documents.Open "H:\SAMDrawing\SAMDraw\Test.vsd"
    7.     vso.Visible = True
    8.     Set shp1Obj = shp1Obj.Import(FName)
    9.     Set vso = Nothing
    10.  
    11.  
    12. End Sub
    this is the error
    object variable or with block not set
    and it point to this line
    Set shp1Obj = shp1Obj.Import(FName)
    "...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?

  35. #35
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Ok, here is whats going on. You need to add the "shp1Obj" to
    the drawing first to create an instance of a Shape object. Then
    after its set you can modify its properties. Let me see if I can get
    it to work.
    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

  36. #36
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    Ok here it is.
    VB Code:
    1. Private Sub cmdRun_Click()
    2.    
    3.     Dim vso As Visio.Application
    4.     Dim vsd As Visio.Document
    5.     Dim vsp As Visio.Page
    6.     Dim shp1Obj As Visio.Shape
    7.    
    8.     Set vso = New Visio.Application
    9.     Set vsd = vso.Documents.Open("H:\SAMDrawing\SAMDraw\Test.vsd")
    10.     vso.Visible = True
    11.     Set vsp = vsd.Pages.Item(1)
    12.     'Change to reflect the path to a image on your system
    13.     Set shp1Obj = vsp.Import("D:\Development\work03.gif")
    14.     shp1Obj.CenterDrawing
    15.  
    16. 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

  37. #37

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    why would it tell me that i need to specify the type of file i am importing?
    "...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?

  38. #38

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    what references did you add to your project?
    "...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?

  39. #39
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709
    I added the reference: "Microsoft Visio 2002 Type Library (Service Release 1)"
    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

  40. #40

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    ok i have the right reference. i get an error now that says visio can't open the file for reading.
    Last edited by Dubya007; Sep 21st, 2004 at 11:40 AM.
    "...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?

Page 1 of 2 12 LastLast

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