NOT selecting shapes on invisible layer with CreateSelection

J

Jacco

Hi,

I'm trying to determine the left uppermost corner for all visible
shapes in a drawing. To exclude some shapes from this operation, I have
temporarily set a layer to invisible and non-printing. If I use the
function [set cSel = expPage.CreateSelection(visSelTypeAll)], the
selection will still include all the shapes on the invisible layer.

What is the correct way of doing this (if there is one)?

Thanks!

Jacco
 
J

JuneTheSecond

Did you checked the example in the help for CreateSelection?
But why you use CreateSelection?
If the shapes are already in the invisible layer.
ActiveWindow.SelctAll would select only visible shapes.
 
J

Jacco

Hi!

Yep, I have checked examples and other documentation. All examples
refer to layers that are visible, or not to layers at all.

I would like to use the CreateSelection function because I'm doing this
for each page in a document, and do not want to show each page to the
user. By walking through the pages, and using this function, it all
happens without being visible to the user.

Maybe I should try the SelectAll function, just to see whether
programmatically it would not select the invisible shapes. I'll try and
do a quick test to see whether this works, but it would seriously slow
down the export process that I'm trying to create.

In short: multiple files need all their pages exported as seperate
images, some layers do not need to be in these images so they are set
to 'invisible' in the process, which works perfectly. However, I also
want to determine the size of the exported image and the left uppermost
corner. To do this, I need to determine the left uppermost corner and
right lowemost corner for the exported page and each of it's background
pages, but without shapes that are on the 'no_export' layers. Does that
make sense?

I'll let you know the outcome of the test, thanks for your quick reply!

Jacco
 
J

Jacco

Yes! The SelectAll method works, thanks for that.

It does require some rewriting of the code, as I now have to activate
the each of the pages. As I export one page in a document, I have to go
through all of its background pages (typically 2 or 3). This means for
each page in the document, 3 or 4 pages are being activated, so this
will probably slow things down a bit.

Any other suggestion as to how to select all visbile objects on a page,
or how to substract objects from a selection, based on a layer?

Cheers!

Jacco
 
J

JuneTheSecond

Then, I thought that you do not need to make any selection nor turn pages.
You have only check the size of the shapes and their layer property, like ...
Sub test2()
Dim pg As Visio.Page
Dim sh As Visio.Shape
Dim I As Long, N As Long

For Each pg In ActiveDocument.Pages
For Each sh In pg.Shapes
N = sh.LayerCount
If N = 0 Then
Debug.Print sh.Cells("Width") & " X " & sh.Cells("Height")
Else
For I = 1 To N
If sh.Layer(I).Name = "inVisible" Then
Debug.Print sh.Cells("Width") & " X " &
sh.Cells("Height")
End If
Next
End If
Next
Next

End Sub
 
J

JuneTheSecond

Sorry.
If sh.Layer(I).Name = "inVisible" Then
should be replaced by
If Not sh.Layer(I).Name = "inVisible" Then
 
J

Jacco

Cheers!

That is definitely another way of doing it. I was hoping that using a
selection would be quicker, not having to loop through all objects. I
should probably do a few tests with both options to see which performs
best.

Thanks again,

Jacco
 
W

wr

Hi Jacco,

In your first mail you mentioned that you use 'visSelTypeAll'
This type will intially select all shapes so irrespective of the layer
This is mentioned in the help section
The sample in the section 'createselection' gives as the correct syntax:
"Set vsoSelection = ActivePage.CreateSelection(visSelTypeByLayer,
visSelModeSkipSuper, vsoLayer)"
If you implement visSelTypeByLayer only the shapes on your specified layer
will be selected.

Still you have to loop through all the pages.
I checked if you could use the master in the documentstencil for it but if
you select
the master (or copy it) those actions only reflect the master not its
instances
(this is opposite to making a chance to the master)

if you use createselection for the master instead of the layer it seems that
it only works for the ActivePage not for the ActiveDocument so you have to
run it for each page

René
 
J

Jacco

Hi René,

Cheers for your reply. What I'm actually trying to do is select ALL
objects on a page, EXCEPT for the objects in one specific layer
('no_export'). I was hoping the visSelTypeAll would let me do this, by
first making the 'no_export' layer invisible (and non-printable).
However, visSelTypeAll will still select all objects, even though they
are invisible.

The workaround with the SelectAll method works (this one does not
select invisible objects, the behaviour I was looking for). The only
drawback is that each page that I want to export will have to be made
active, including all of its background pages. The other function was
able to do this on a page object, rather than the ActivePage object.
This means it is a little slower, but I'm happy it works!

Thanks again though!

Jacco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top