基于cdr的一种批量导入图片生成批量cdr文件的方法

Sub PLinsert()
    cdrpath = InputBox("请输入cdr文件路径:", "FilePath", "示例:D:\cdr") & "\"
    cdrFile = Dir(cdrpath & "*.jpg")
    Do While cdrFile <> ""
    Dim createopt As StructCreateOptions
    Set createopt = CreateStructCreateOptions
    With createopt
        .Name = "未命名 -1"
        .Units = cdrMillimeter
        .PageWidth = 297#
        .PageHeight = 210#
        .Resolution = 600#
        .ColorContext = CreateColorContext2("sRGB IEC61966-2.1,Japan Color 2001 Coated,Dot Gain 15%", BlendingColorModel:=clrColorModelCMYK)
    End With
    Dim doc1 As Document
    Set doc1 = CreateDocumentEx(createopt)
    ActiveDocument.Unit = cdrMillimeter
    ActivePage.SetSize 70, 45
    Dim impopt As StructImportOptions
    Set impopt = CreateStructImportOptions
    With impopt
        .Mode = cdrImportFull
        .MaintainLayers = True
        With .ColorConversionOptions
            .SourceColorProfileList = "sRGB IEC61966-2.1,Japan Color 2001 Coated,Dot Gain 15%"
            .TargetColorProfileList = "sRGB IEC61966-2.1,Japan Color 2001 Coated,Dot Gain 15%"
        End With
    End With
    Dim s1 As Shape
    Set s1 = ActiveLayer.CreateRectangle(0#, 45, 70, 0#)
    s1.Rectangle.CornerType = cdrCornerTypeRound
    s1.Rectangle.RelativeCornerScaling = True
    s1.Fill.ApplyNoFill
    s1.Outline.SetPropertiesEx 0.007874, OutlineStyles(0), CreateCMYKColor(0, 0, 0, 100), ArrowHeads(0), ArrowHeads(0), cdrFalse, cdrFalse, cdrOutlineButtLineCaps, cdrOutlineMiterLineJoin, 0#, 100, MiterLimit:=5#, Justification:=cdrOutlineJustificationMiddle
    With ActivePage
        .SetSize 70, 45
        .Orientation = 1
        .PrintExportBackground = True
        .Bleed = 0.15748
        .Background = 0
    End With
    s1.Style.StringAssign "{""fill"":{""primaryColor"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000"",""secondaryColor"":""CMYK,USER,0,0,0,0,100,00000000-0000-0000-0000-000000000000""},""outline"":{""width"":""3528"",""color"":""CMYK,USER,0,0,0,100,100,00000000-0000-0000-0000-000000000000""},""transparency"":{}}"
    Dim impflt As ImportFilter
    Set impflt = ActiveLayer.ImportEx(cdrpath & cdrFile, cdrJPEG, impopt)
    impflt.Finish
    ActiveLayer.Shapes(1).AddToPowerClip s1
    Dim SaveOptions As StructSaveAsOptions
    Set SaveOptions = CreateStructSaveAsOptions
    With SaveOptions
        .EmbedVBAProject = False
        .Filter = cdrCDR
        .IncludeCMXData = False
        .Range = cdrAllPages
        .EmbedICCProfile = False
        .Version = cdrVersion21
        .KeepAppearance = True
    End With
    doc1.SaveAs cdrpath & cdrFile & ".cdr", SaveOptions
    doc1.Close
    cdrFile = Dir
    Loop
End Sub

  • 9
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值