A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Visio
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

VBA - removing object from layer



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2009, 05:03 PM posted to microsoft.public.visio.general
external usenet poster
 
Posts: 32
Default VBA - removing object from layer

I am using the following macro to selectively add connectors to a
specific layer. There is a complication though: every connector on my
page belongs to a layer called 'connector', which I don't want. I want
to somehow remove everything from that layer without deleting the
shapes, or remove every shape from that layer.

Is there a variation of this code that will remove something from a
layer? I have tried many permutations but with no success. Thanks in
advance!

---

Public Sub MoveToLayer()

Dim objShps As Visio.Selection, objShp As Visio.Shape
Dim objLayers As Visio.Layers, objLayer As Visio.Layer
Dim i As Integer

'get the Selection
Set objShps = Visio.ActiveWindow.Selection

'get the layers collection
Set objLayers = Visio.ActivePage.Layers
Set objLayer = objLayers("Shapes")

For i = 1 To objShps.Count
Set objShp = objShps(i)
objLayer.Add objShp, 0
Next i

End Sub
Ads
  #2  
Old January 14th, 2009, 05:18 PM posted to microsoft.public.visio.general
AlEdlund[_2_]
external usenet poster
 
Posts: 76
Default VBA - removing object from layer


shapes often bring along a default layer with them. I usually add something
like this just after
I drop them on the page

visShape.CellsSRC(visSectionObject, visRowLayerMem,
visLayerMember).FormulaForceU = """"""

hth,
al


wrote in message
...
I am using the following macro to selectively add connectors to a
specific layer. There is a complication though: every connector on my
page belongs to a layer called 'connector', which I don't want. I want
to somehow remove everything from that layer without deleting the
shapes, or remove every shape from that layer.

Is there a variation of this code that will remove something from a
layer? I have tried many permutations but with no success. Thanks in
advance!

---

Public Sub MoveToLayer()

Dim objShps As Visio.Selection, objShp As Visio.Shape
Dim objLayers As Visio.Layers, objLayer As Visio.Layer
Dim i As Integer

'get the Selection
Set objShps = Visio.ActiveWindow.Selection

'get the layers collection
Set objLayers = Visio.ActivePage.Layers
Set objLayer = objLayers("Shapes")

For i = 1 To objShps.Count
Set objShp = objShps(i)
objLayer.Add objShp, 0
Next i

End Sub


  #3  
Old January 14th, 2009, 05:25 PM posted to microsoft.public.visio.general
external usenet poster
 
Posts: 32
Default VBA - removing object from layer

I am familiar with that line of code, but I'm wondering if there is
anything I can do about it now, after the connectors are already on
the page?

Thanks
  #4  
Old January 14th, 2009, 05:38 PM posted to microsoft.public.visio.general
AlEdlund[_2_]
external usenet poster
 
Posts: 76
Default VBA - removing object from layer

If your attempting to ensure that the connector is on only one layer then
put it between
these two instructions

Set objShp = objShps(i)

objShpe.CellsSRC(visSectionObject,
visRowLayerMem, visLayerMember).FormulaForceU = """"""

objLayer.Add objShp, 0

al

wrote in message
...
I am familiar with that line of code, but I'm wondering if there is
anything I can do about it now, after the connectors are already on
the page?

Thanks


  #6  
Old January 14th, 2009, 05:52 PM posted to microsoft.public.visio.general
external usenet poster
 
Posts: 32
Default VBA - removing object from layer

Thank you very much.
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:53 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 OfficeFrustration.
The comments are property of their posters.