Hi. I'm totally new to VBA and Corel Macros, but I'M getting better and better. I usually code in Java or Javascript.
I want to export all (top layer) grouped shapes. But before exporting, i wan't to hide (remove) the outlines (wich match specific colors) and after export i want to apply them again.
What i want from Corel is to loop throu my shapes (wich are grouped) and search for shapes within them to find outlined shapes with specific colors.
Then i want to remove them but i also need to store them to apply the removed color again. Butthat doesn't work.
I can do
Shape.Outline.SetNoOutline
But when i do
HiddenOutlines(index) = Shape.Outline
Here is my code:
'Colors i want to hide when exporting and to show after it. Are loaded from a file. Already works, but isn't shown here'Dim ExcludeColors() As String
'Colors i want to hide when exporting and to show after it. Are loaded from a file. Already works, but isn't shown here'
Dim ExcludeColors() As String
'Array to store the outlines'Dim hiddenOutlines() As Outline
'Array to store the outlines'
Dim hiddenOutlines() As Outline
For i = 1 To ActiveDocument.Pages.Count For j = 1 To ActiveDocument.Pages(i).Shapes.Count For k = 1 To ActiveDocument.Pages(i).Shapes(j).Shapes.Count 'Compare outline color with colors to exclude (ExcludeColors)' For Each EColor In ExcludeColors If ActiveDocument.Pages(i).Shapes(j).Shapes(k).Outline.Color.HexValue = EColor Then ActiveDocument.Pages(i).Shapes(j).Shapes(k).Outline.SetNoOutline 'Resize Array +1' Dim arrLength As Integer arrLength = UBound(hiddenOutlines) - LBound(hiddenOutlines) + 1 ReDim Preserve hiddenOutlines(arrLength + 1) 'Not shure if it should be arrLength or arrLength + 1' hiddenOutlines(arrLength) = ActiveDocument.Pages(i).Shapes(j).Shapes(k).Outline 'Runtime Error 91 object variable or with block variable not set ' End If Next 'Select and save the shape (ActiveDocument.Pages(i).Shapes(j).Shapes(k))' Next k Next jNext i
For i = 1 To ActiveDocument.Pages.Count
For j = 1 To ActiveDocument.Pages(i).Shapes.Count
For k = 1 To ActiveDocument.Pages(i).Shapes(j).Shapes.Count
'Compare outline color with colors to exclude (ExcludeColors)'
For Each EColor In ExcludeColors
If ActiveDocument.Pages(i).Shapes(j).Shapes(k).Outline.Color.HexValue = EColor Then
ActiveDocument.Pages(i).Shapes(j).Shapes(k).Outline.SetNoOutline
'Resize Array +1'
Dim arrLength As Integer
arrLength = UBound(hiddenOutlines) - LBound(hiddenOutlines) + 1
ReDim Preserve hiddenOutlines(arrLength + 1)
'Not shure if it should be arrLength or arrLength + 1'
hiddenOutlines(arrLength) = ActiveDocument.Pages(i).Shapes(j).Shapes(k).Outline 'Runtime Error 91 object variable or with block variable not set '
End If
Next
'Select and save the shape (ActiveDocument.Pages(i).Shapes(j).Shapes(k))'
Next k
Next j
Next i
'Normaly i would use hiddenOutlines here to apply outlines to them'
Instead of trying to "manually" undo the changes to outlines, have you considered trying a strategy like this?
I haven't tried this, so I don't know that it does what you need. It's just an idea you might consider.
Another strategy might be to perform all of the changes inside a command group, and then Undo after exporting. Again, I haven't tried doing that.
Thank you for the answer. That's also possible. But it would be nice if the macro does everything for me. And i would really like to know how to store the outlines.