VBA:文档中存在引用的对象no loger

时间:2015-08-10 21:46:39

标签: vba coreldraw

在循环中,前三个命令是成功的。 但不是循环的第四行 - 那里有一个错误。 我们能够为outlineShape设置属性但是焊接有什么问题?

Dim outlineShape As Shape
Dim weldShape As Shape

For Each s In sr

        Set outlineShape = s.Outline.ConvertToObject
        outlineShape.Fill.UniformColor.CMYKAssign 100, 0, 0, 0
        s.Fill.UniformColor.CMYKAssign 0, 0, 0, 50

        ' Set weldShape = outlineShape.Weld(s)    ' error here! Method Weld of object IDrawShape failed
        ' in debagger, the line shows: The referenced object no loger exist in the document

Next s

1 个答案:

答案 0 :(得分:0)

使用corel x6正常工作。

Sub test()
    Dim outlineShape As Shape
    Dim weldShape As Shape
    Dim s As Shape

    For Each s In ActiveDocument.ActiveLayer.Shapes

            Set outlineShape = s.Outline.ConvertToObject
            outlineShape.Fill.UniformColor.CMYKAssign 100, 0, 0, 0
            s.Fill.UniformColor.CMYKAssign 0, 0, 0, 50

            Set weldShape = outlineShape.Weld(s)    
    Next s


End Sub

尝试将s声明为Shape,将sr更改为“shape array”。 我认为,问题在于你的sr对象不是你需要的类型。