Copy link to clipboard
Copied
Hi, I am trying to place objects (some img files) in an illustrator file, using VBA/excel.
filePath = ActiveWorkbook.Path
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open(filePath & "\test.AI")
Set placedItem = docRef.placedItems.Add()
'placedItem.File = File("\test.png")
The code up to appRef.Open(path) works - it opens the illustrator file.
But I cannot figure out how to use placeditems.Add(), or whatever necessary to place the image.
for svg and probably dxf, use the Group's CreateFromFile method
Set igroup = docRef.GroupItems.CreateFromFile("C:/Users/Canto/full path to your file.svg")
Copy link to clipboard
Copied
This code works:
Dim filePath As String
filePath = ActiveWorkbook.Path
Set appRef = CreateObject("Illustrator.Application")
Set docRef = appRef.Open(filePath & "\5x10_NEW.AI")
Set placedItem = docRef.placedItems.Add()
placedItem.File() = filePath & "\_QR\123.jpg"
Now I have a problem placing .svg graphics.
I am trying to automate a very tedious task of manually placing a lot of different .svg files.
I do that manually (file/place/.svg images), but when I use placedItems.Add(), there is an error, that the format cannot be accepted 😞
Copy link to clipboard
Copied
Cannot work with .dxf as well.
It works ok when I place .dxf manually.
Could it be that it cannot work with vector graphics?
Mby I have to scale the graphics first to some dimensions?
Copy link to clipboard
Copied
for svg and probably dxf, use the Group's CreateFromFile method
Set igroup = docRef.GroupItems.CreateFromFile("C:/Users/Canto/full path to your file.svg")
Copy link to clipboard
Copied
^^Thinks !!! It works !!!
Didn't read and search through the scripting manual: AI CC Scripting Reference: VBScript
- page 90
I was going to try some nasty workarounds, importing images, then trace, and so on....
Copy link to clipboard
Copied
I was going to try some nasty workarounds, importing images, then trace, and so on....
By @emosms
ouch!! nasty! hahaha