PasteFromAI_Smart_Coreldraw
Sub PasteFromAI_Smart()
Dim sr As ShapeRange
' Optimize performance by disabling screen refresh
Optimization = True
ActiveDocument.BeginCommandGroup "Paste from AI"
On Error Resume Next
' Clear selection to ensure we identify newly pasted objects later
ActiveDocument.ClearSelection
' --- ATTEMPT 1: PDF (Best quality, correct scale) ---
ActiveLayer.PasteSpecial "Portable Document Format"
' If failed, try next format
If Err.Number <> 0 Then
Err.Clear
' --- ATTEMPT 2: Adobe Illustrator (AICB) ---
ActiveLayer.PasteSpecial "Adobe Illustrator Format"
If Err.Number <> 0 Then
Err.Clear
' --- ATTEMPT 3: PDF (Short name variant) ---
ActiveLayer.PasteSpecial "PDF"
If Err.Number <> 0 Then
Err.Clear
' --- FALLBACK: Standard Paste (May result in EMF/Wrong Scale) ---
ActiveLayer.Paste
End If
End If
End If
' Verify if anything was pasted
Set sr = ActiveSelectionRange
' Restore environment settings
ActiveDocument.EndCommandGroup
Optimization = False
ActiveWindow.Refresh
End Sub
