I have a VBA script I am working on in which I collect a number of image layers into a range object. I use the Combine() method which should return a layer object, but I cannot see to set it to a variable for further processing. "pix" variable here is the current image document in this code fragment.
Set myLayers = New LayerRange' Add layers to rangemyLayers.Add pix.Layers.Item("a")myLayers.Add pix.Layers.Item("b")myLayers.Add pix.Layers.Item("c")myLayers.Add pix.Layers.Item("d")' Combine layers to new layerSet newLayer = myLayers.Combine()
Set myLayers = New LayerRange
' Add layers to range
myLayers.Add pix.Layers.Item("a")
myLayers.Add pix.Layers.Item("b")
myLayers.Add pix.Layers.Item("c")
myLayers.Add pix.Layers.Item("d")
' Combine layers to new layer
Set newLayer = myLayers.Combine()
However newLayer is still nothing. The image still shows layer "a" as the combined layers "a" through "d" in Object Manager. Although "pix" the current document has "a" at index 2 in Items collection:
TypeName(newlayer) returns 'nothing'
TypeName(pix.Layers.Item("a")) returns 'iPaintLayer'
TypeName(pix.Layers.Item(2)) returns 'iPaintLayer'
So the layer seems to be there but cannot be accessed or assign to a variable. If you try you get a runtime error 'The references object doesn't exist anymore. So how do you combine several layer objects to a single layer object and access it afterwards?
--
Jonathan
Yes, for example I have created scripts that do preparatory work. One that strips EXIF info from images making images smaller for web sites. Auto resizing to a max size also for websites, in fact one for one of my websites that resizes, create thumbnails, and code fragment for a one-click process to maintain that site. Others for one-click to modify scan drawings as preparation for tracing to make DRAW lineart. And the list goes on...
Like I said you must have repetitive work for a Macro to be useful. From my view with alot of repetitive work euthanasia can be useful.