I'm presently preparing a diagram of sorts and thus far the code has gone swimmingly, until now. I've been able to achieve "hide all" and "show all" as well as showing isolated layers and hiding the rest with the: Call ShowLayers("loadlist") for instance. Problem is I'm learning as I go, the book I have needs to be tossed, and I'm trying to do something that I'm not entirely sure visio supports. Instead of showing just one layer or step in the process isolated from everything else (when the commandbutton is clicked) can I simply highlight or stroke the layer with a certain color? To complicate things I have one database object that is in several layers, so that may present an issue if this is even possible. sample code is below.
Thanks for taking time to read this!
Q
sample::
Private Sub ShowLayers(ThisLayer)
Dim LayersObj As Visio.Layers
Dim LayerObj As Visio.Layer
Dim LayerName As String
Dim LayerCellObj As Visio.Cell
Set LayersObj = ActivePage.Layers
For Each LayerObj In LayersObj
LayerName = LayerObj.Name
' Debug.Print LayerName
If LayerName = ThisLayer Or LayerName = "Connector" Then
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
LayerCellObj.Formula = True
Else
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
LayerCellObj.Formula = False
End If
Next
End Sub
Private Sub AllLayers(OnOrOff)
Dim LayersObj As Visio.Layers
Dim LayerObj As Visio.Layer
Dim LayerName As String
Dim LayerCellObj As Visio.Cell
Set LayersObj = ActivePage.Layers
For Each LayerObj In LayersObj
LayerName = LayerObj.Name
Set LayerCellObj = LayerObj.CellsC(visLayerVisible)
LayerCellObj.Formula = OnOrOff
Next
End Sub
Private Sub CommandButton1_Click()
Call ShowLayers("loadlist")
End Sub
Hi QE,
This is a little snippet that will color a layer red:
Dim visPg as Visio.Page
Dim visLyr as Visio.Layer
Set visPg = Visio.ActivePage
Set visLyr = visPg.Layers("Bob")
visLyr.CellsC(visio.VisCellIndices.visLayerColor).Formula = "RGB(255,0,0)"
You can clear the layer coloring by wiping the formula clean:
visLyr.CellsC(visio.VisCellIndices.visLayerColor).Formula = ""
Or by setting the result to 0:
visLyr.CellsC(visio.VisCellIndices.visLayerColor).ResultIU = 0
Most excellent! I just wanted to take some time here to thank you for your prompt response on this issue. I've come to really love the Visio program and I will be using this with all my customers (Mac and PC). Good to know that such an involved community exists to help each other out and hopefully, one day I can steer someone in the right direction or help with a bit of code. Many thanks again! :)
Sometimes it may be necessary to take an extra step to ensure that when we move shapes between layers, that they reflect the color of the layer we move them to...
HTH
al
' this is where we set it up so that the outline color reflects the layer selected
' we end up forcing the line style and color just so the object is aware......
' since layer color affects lines and if the shape is a group the top shape may
' not have lines that we can alter, so move into subshapes to make it happen
Private Sub MakeLayerAware(visShape As Visio.Shape)
Dim shpCell As Visio.Cell
Dim visEmbShape As Visio.Shape
Set shpCell = visShape.CellsSRC(Visio.visSectionObject, visRowLine, visLineColor)
shpCell.Formula = visBlack
Set shpCell = visShape.CellsSRC(Visio.visSectionObject, visRowLine, visLinePattern)
shpCell.Formula = visSolid
If visShape.Type = visTypeGroup Then
'Debug.Print "it is a group"
Set visEmbShape = visShape.Shapes(1)
'Debug.Print "instantiate an embedded shape"
Set shpCell = visEmbShape.CellsSRC(Visio.visSectionObject, visRowLine, visLineColor)
shpCell.Formula = visBlack
Set shpCell = visEmbShape.CellsSRC(Visio.visSectionObject, visRowLine, visLinePattern)
shpCell.Formula = visSolid
' how wide to make the line
Set shpCell = visEmbShape.CellsSRC(Visio.visSectionObject, visRowLine, visLineWeight)
shpCell.Formula = 0.01
End If
End Sub
Browser ID: smf
(is_webkit)
Templates: 1:
Printpage (default).
Sub templates: 4:
init,
print_above,
main,
print_below.
Language files: 1:
index+Modifications.english (default).
Style sheets: 0:
.
Hooks called: 49 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 925KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 771KB.
Tokens:
post-login.
Cache hits: 6: 0.00102s for 22,291 bytes (
showget modSettings: 0.00046s - 19982 bytes, get known_languages: 0.00017s - 1277 bytes, get board_parents-0: 0.00013s - 2 bytes, get permissions:-1: 0.00009s - 50 bytes, get theme_settings-1: 0.00014s - 980 bytes, get menu_buttons--1-english: 0.00001s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 8.
[Show Queries]