我正在尝试创建一个基于页面文本的IF函数。
我正在处理打印合并和填充数十个合并字段,这些字段被隐藏起来,并被分离成层,其中有对象,基于它们所使用的样式。
然后,我手动为该样式设置visibility = True。
我知道这个语法是错误的,但为了解释,我想做的是;
If Layer("Style") contains text "MyStyleName"
Layer("MyStyleName").Visible = True我目前正在将这段代码与MyStyleLayer1一起使用到MyStyleLayer13左右
If ActivePage.Layers("MyStyleLayer1").Visible = True Then
ActivePage.Layers("MyStyleLayer1").Visible = False
Else: ActivePage.Layers("MyStyleLayer1").Visible = True
End If每个样式层都分配给键盘快捷方式,并手动显示或隐藏。
我试图使这个过程自动化
发布于 2015-12-20 17:55:58
若要隐藏名为contian 'Layer‘的层,可以使用以下代码
Sub HideLayer()
' Recorded 20.12.2015
Dim Mylayer As Layer
Dim searchstring As String
searchstring = "Layer"
For Each Mylayer In ActivePage.Layers
If InStr(1, Mylayer.Name, searchstring) > 0 Then
Mylayer.Visible = False
End If
Next
End Sub显示图层变化
Mylayer.Visible = False至
Mylayer.Visible = true若要在页面上搜索文本中的字符串,请使用以下代码
Public Sub TextFind()
Dim s As Shape
Dim WhatFind as String
Dim CountFind as integer
CountFind = 0
WhatFind = "I"
For Each s In ActiveDocument.ActivePage.Shapes
If s.Type = cdrTextShape Then
If InStr(1, s.Text.Story, WhatFind) > 0 Then
CountFind=CountFind+1
End If
End If
Next
If CountFind > 0 Then ' do what you want when WhatFind had searched in text
End If
End Subhttps://stackoverflow.com/questions/34379930
复制相似问题