Home > Software engineering >  What is causing this CorelDraw VBA Macro Mismatch Error?
What is causing this CorelDraw VBA Macro Mismatch Error?

Time:06-02

I have a short Excel VBA macro that takes the current selection in an (open) CorelDraw drawing and moves it. Why am I getting a mismatch runtime error when I set OrigSelection to be the app.ActiveSelectionRange? Here is my code:

Private Sub MoveAndResizeSelection()
    Dim app As CorelDraw.Application
    Set app = CorelDraw.Application
    Dim OrigSelection As ShapeRange
    Set OrigSelection = app.ActiveSelectionRange
    
    'Move and Resize the selection
    OrigSelection.Move 2.595, -6.751
    
End Sub

I am using Excel Office 16 and CorelDraw Graphics Suite 2022.

CodePudding user response:

The culprit is

Dim OrigSelection As ShapeRange

which is implicitly

Dim OrigSelection As Excel.ShapeRange

Change to

Dim OrigSelection As CorelDraw.ShapeRange
  • Related