Hello, im trying to make a macro with zero knowledge about script. The purpose of the macro is to export JPG to same folder location as CDR file, named with size (width & Height). ( and maybe, adding a custom text is pretty cool)
my intial design is in scale size 1:10 (ex. for 1 meter design, im designing in 10 cm)
setting for my export is
for file name usually i'll do
"custom text (280-340-kr)" - Width size x Height size - "custom text (mta-lp-etc)"
How do make code with setting above ?
Here's code that i took form this forum (code from Shelby Moore and Mek) and i'm trying to edit, but failed hehe.
Sub ExportJPEGCMYK() Dim OrigSelection As ShapeRange Set OrigSelection = ActiveSelectionRange OrigSelection.CreateSelection Dim expopt As StructExportOptions ActiveDocument.Unit = cdrCentimeter Set expopt = CreateStructExportOptions fnp = ActiveDocument.FilePath dn = Left$(ActiveDocument.FileName, Len(ActiveDocument.FileName) - 4) & ".jpg" Dim expflt As ExportFilter Set expflt = ActiveDocument.ExportEx(fnp + dn, cdrJPEG, cdrSelection, expopt) With expflt .AntiAliasingType = cdrNormalAntiAliasing .ImageType = cdrCMYKColorImage .Overwrite = True .ResolutionX = 72 .ResolutionY = 72 .SizeX = expopt.ResolutionX * ActiveSelectionRange.SizeWidth .SizeY = expopt.ResolutionY * ActiveSelectionRange.SizeHeight End WithEnd Subthanks
After some editing & searching, i come up with this code.
Sub ExportJPEGScale()
Dim s As Shape Dim OrigSelection As ShapeRange Dim sc As String Set OrigSelection = ActiveSelectionRange sc = InputBox("Export Description", "Export JPEG") OrigSelection.CreateSelection 'ActiveSelection.SetSize ActiveSelection.SizeWidth * 10, ActiveSelection.SizeHeight * 10 Dim expopt As StructExportOptions ActiveDocument.Unit = cdrCentimeter
Set expopt = CreateStructExportOptions fnp = ActiveDocument.FilePath dn = (Round(OrigSelection.SizeWidth, 0)) & " × " & (Round(OrigSelection.SizeHeight, 0)) & " cm " & (sc) & ".jpg" Dim expflt As ExportFilter Set expflt = ActiveDocument.ExportBitmap(fnp + dn, cdrJPEG, cdrSelection, cdrCMYKColorImage, OrigSelection.SizeWidth * 100, OrigSelection.SizeHeight * 100, 72, 72, cdrNormalAntiAliasing, False, True, True, False, cdrCompressionNone) With expflt .Smoothing = 50 .Compression = 15 .Finish End With 'ActiveDocument.Undo (0)
End Sub
as you can see, i put resize code into comment, because it is not solution for 1000% scale for my export setting, because outline not getting scaled.
after that, im trying to put object size and multiply it by 10. but output file reads it as pixel when it supposedly to be cm (e.g : file is 10 cm, exported file is 100 px).
im still trying to figure out the solution.
Robby,
Could you include a sample cdr file that shows the issue?
Thanks,
-Shelby