Export to DXF active document

Hello,

I am new Corel and I am trying to do a Macro. I used the recording tool. I want to take a selection, convert to curves, turn it black then export it to ".dxf" in folder location. It works but I can't figure out how to make it so it has the same name as the active document. It always ends up with "778819.dxf".

I have been trying to figure it out myself but I am having a hard time since I am new to coding and I don't really understand how the "ActiveDocument" thing works.

Here is the code:

Sub DXF()
' Recorded 4/11/2016
Dim OrigSelection As ShapeRange
Set OrigSelection = ActiveSelectionRange
OrigSelection.ConvertToCurves
OrigSelection.ApplyUniformFill CreateCMYKColor(0, 0, 0, 100)
OrigSelection.CreateSelection
Dim expopt As StructExportOptions
Set expopt = CreateStructExportOptions
expopt.UseColorProfile = False
Dim expflt As ExportFilter
Set expflt = ActiveDocument.ExportEx("F:\LASIT\_DXF Files\778819.dxf", cdrDXF, cdrSelection, expopt)
With expflt
.BitmapType = 0 ' FilterDXFLib.dxfBitmapJPEG
.TextAsCurves = True
.Version = 11 ' FilterDXFLib.dxfVersion2006
.Units = 3 ' FilterDXFLib.dxfMillimeters
.FillUnmapped = True
.FillColor = 0
.Finish
End With
End Sub

Parents
  • You can try code below, export selection as dxf to the same directory as cdr file is saved

    Sub DXF()
    ' Recorded 4/11/2016
    Dim OrigSelection As ShapeRange
    Set OrigSelection = ActiveSelectionRange
    OrigSelection.ConvertToCurves
    OrigSelection.ApplyUniformFill CreateCMYKColor(0, 0, 0, 100)
    OrigSelection.CreateSelection
    Dim expopt As StructExportOptions
    Set expopt = CreateStructExportOptions
    expopt.UseColorProfile = False
    fnp = ActiveDocument.FilePath
    dn = Left$(ActiveDocument.FileName, Len(ActiveDocument.FileName) - 4) & ".dxf"
    Dim expflt As ExportFilter
    Set expflt = ActiveDocument.ExportEx(fnp + dn, cdrDXF, cdrSelection, expopt)
    With expflt
    .BitmapType = 0 ' FilterDXFLib.dxfBitmapJPEG
    .TextAsCurves = True
    .Version = 11 ' FilterDXFLib.dxfVersion2006
    .Units = 3 ' FilterDXFLib.dxfMillimeters
    .FillUnmapped = True
    .FillColor = 0
    .Finish
    End With
    ActiveDocument.Undo (2)
    End Sub
    Best regards
    Mek
Reply Children
No Data