选择要在所有页面上搜索的层

  • 本文关键字:搜索 选择 vba coreldraw
  • 更新时间 :
  • 英文 :


这是我使用的代码的一部分;

Dim s As Shape
Dim p As Page, numberPage As Integer
Dim i&
Dim WhatSamp As String
WhatSamp = "Sample1"
For i = 1 To ActiveDocument.Pages.Count
ActiveDocument.Pages(i).Activate
For Each s In ActiveDocument.ActivePage.Shapes
If s.Type = cdrTextShape Then
     If InStr(1, s.Text.Story, WhatSamp) > 0 Then
     ActivePage.Layers("Sample").Visible = True
     ActivePage.Layers("Sample").Printable = True
     End If
End If
Next
Next i

我使用的代码要长得多,但我相信这是相关的部分。

它在页面上搜索我的文本(Sample1),然后显示并打印名为"Sample"的层。

我认为,因为我需要大量的层,所以运行需要很长时间

所以,我试图让它只在每一页上的一个名为"样式"的特定层上搜索我的文本,但我似乎无法理解。

提前谢谢。

请告诉我是否需要更多信息

若要测试对象"S"是什么层,请使用

 if S.Layer.Name="Style" then

然后

If InStr(1, s.Text.Story, WhatSamp) > 0 Then
 ActivePage.Layers("Sample").Visible = True
 ActivePage.Layers("Sample").Printable = True

最新更新