Search code examples
vbavb6photoshopui-automationadobe-illustrator

VB: Assigning to a Boolean property in Adobe Illustrator, Photoshop


While automating Adobe Illustrator CS3 using VBA I discovered that assigning a Boolean variable to a Boolean property results in assigning False always:

Dim New_Path As Illustrator.PathItem
Dim v As Boolean
' ...
v = True
New_Path.Filled = v     ' ERROR: New_Path.Filled is False
v = False
New_Path.Filled = v     ' New_Path.Filled remains False

Assigning to a constant works fine:

Dim New_Path As Illustrator.PathItem
' ...
New_Path.Filled = True  ' New_Path.Filled is True
New_Path.Filled = False ' New_Path.Filled is False

Verified for various AI Boolean properties such as PathItem.Stroked, Layer.Visible etc.

Verified for Photoshop.ArtLayer.Visible.

Verified for VB6.

So, I feel that this behavior is common for Adobe Adobe Creative Suite products.

Is this a bug or a feature?


Solution

  • Wrap the v variable with CBool() function.