hello, i have been able (with lots of help) to make shapes and position them in visio2000. but now what i need to do is be able to select more than one item and group them as one shape. any ideas?
Printable View
hello, i have been able (with lots of help) to make shapes and position them in visio2000. but now what i need to do is be able to select more than one item and group them as one shape. any ideas?
so sorry to ask, but what is visio2000? and what does it have to do with VB?
Visio2000 is a microsoft program that is used for flowcharts graphical things for reports etc. i have used VB6 to open it, and to put some data and other things in there, i just need to know if it is possible to group from VB6.
Hey Dubya007, I see your on the project again. I know there is a
way to do it. I was starting to try it out last time we were
working on the shape adding/positioning. Let me see if I can find
it again.
Hey RobDogg good to hear from you again. i didn't think of that earlier. but now i have to do it. i have been looking on the net for a way, i think that i may have found a way but it doesn't seem to work. i think that it has some thing to do with
activewindow.select
but i am unsure
Same here!
Look into the Shape methods. I am quite sure it was in there. The
methods Group and UnGroup. I'm a little busy but I will try to help
as I get the time.
ok sounds good. if i find it i will let you know,so that you'll have it in case you ever need it.
Thanks. :thumb:
When you get a second take a look at this code
not sure why but i get the following error do i need to add a library or something?VB Code:
Dim y As String Dim x As Variant With VisioDocument.Pages("Page-1") For Each x In .Shapes y = Right(x.Name, Len(x.Name) - InStrRev(x.Name, ".")) Select Case y Case 64, 65, 66, 67, 68, 69, 70 ActiveWindow.Select x, visSelect End Select Next ActiveWindow.Group End With
ERROR
ActiveX component cant create object
That looks too error prone. :(
Try duplicating this example from the Visio help file.
Groups the objects that are selected in a selection, or it converts
a shape into a group.
:DVB Code:
'This Microsoft Visual Basic for Applications (VBA) macro 'demonstrates dropping shapes using the Page, Document, 'and Shape objects. Public Sub Drop_Example () Dim shp1Obj As Visio.Shape Dim shp2Obj As Visio.Shape Dim shp3Obj As Visio.Shape Dim mstObj As Visio.Master Set shp1Obj = ActivePage.DrawRectangle(1, 2, 2, 1) Set shp2Obj = ActivePage.DrawRectangle(1, 4, 2, 3) 'Example of Page.Drop ActivePage.Drop shp1Obj, 3.5, 3.5 Set shp3Obj = ActivePage.Shapes(3) 'Example of Document.Drop - Creates a master Set mstObj = ActiveDocument.Drop(shp3Obj, 0, 0) 'Example of Shape.Drop ActiveWindow.DeselectAll ActiveWindow.Select shp1Obj, visSelect ActiveWindow.Select shp2Obj, visSelect ActiveWindow.[b]Group[/b] Set shp1Obj = ActivePage.Shapes(2) shp1Obj.Drop shp3Obj, 3, 3 End Sub
i tried this in there just to see if it would work
ActiveWindow.DeselectAll
and i got the same error so, in light of that i need to figure out why that wouldn't work then maybe i can select the rest of the thing right?
Try this to add the selected shapes as a group.
VB Code:
ActiveWindow.AddToGroup
And to ungroup a selected shape...
VB Code:
ActiveWindow.RemoveFromGroup
i think that the error is coming from ActiveWindow. the debugger always points to the first line that says active window
Try running it without stepping through the code. I think that since
you may be stepping, there is no active window.
i tried it and i still get the error. do you think that when the visiodocument is opened that i should activate it some how. like put in
Code:ActiveWindow.Enabled
'or
ActiveWindow.Activate 'is that even one?
If you are coding from VB6, you must have some application object.
I think you need to add this to the code, because vb doesn't know that ActiveWindow has something to do with visio.
Something like:
appVisio.ActiveWindow.Select x, visSelect
yeah that is what you have to do, i was just going to get on and type back the solution. thanx for the help.
VB Code:
VisioApplication.ActiveWindow.DeselectAll
any one know if it is possible to change the size of the shapes from vb6?
Hey Dubya, Sup!
I thought we covered that in the original thread? Remember PinX
and PinY I believe it was.
Sup Dogg,
the PinX and the PinY were dealing with the positioning of the shape. if the cell of the shape is set to the center then the PinX & PinY are the coordinates of the center cell.
Ok, I opened my VB_Visio project and here is the code.
We did use this in the beginings of the original thread.VB Code:
'Stretch image shp1Obj.Cells("Width") = 2 'Unit is Inches shp1Obj.Cells("Height") = 2.5
:D