问题
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?
回答1:
Wrap the v variable with CBool() function.
来源:https://stackoverflow.com/questions/27482952/vb-assigning-to-a-boolean-property-in-adobe-illustrator-photoshop