I built a class module in Access 2007 using VBA for automating Photoshop. It worked so well that I decided to port it to a standalone application, and installed Visual Basic Express 2008. Come to find out VB2008 is not just a simple upgrade from from VB6 or VBA, they changed a lot with the new .NET framework. But I'm getting most of it to work, unfortunately the one procedure I use most:
CODE
Public Sub SelectArea(l As Integer, t As Integer, w As Integer, h As Integer)
Dim p(1 To 5) As Variant
p(1) = Array(l, t)
p(2) = Array(w + l, t)
p(3) = Array(w + l, t + h)
p(4) = Array(l, t + h)
p(5) = Array(l, t)
ps.ActiveDocument.Selection.Select p
End Sub
Didn't port over easily. The Photoshop dox are skimpy, but thie Select method expects an array of arrays and this code worked perfectly. The VB2008 code I wrote appears to be functionally identical:
CODE
Public Sub SelectArea(ByVal l As Integer, ByVal t As Integer, ByVal w As Integer, ByVal h As Integer)
Dim p1() = {2, 2}
Dim p2() = {12, 2}
Dim p3() = {12, 12}
Dim p4() = {2, 12}
Dim p5() = {2, 2}
Dim p()() = {p1, p2, p3, p4, p5}
PSapp.ActiveDocument.Selection.Select(p)
End Sub
The values were plugged in to make it easier to debug. When I call this I get a
CODE
[b]System.Runtime.InteropServices.SafeArrayTypeMismatchException[/b]
I've tried several variations on this theme, specifying other types, most of which won't even compile. I've tried to shut off the exception handling for this error, and handling the error myself but with no luck. I'm
desperate at this point, only because this little app cuts my image processing time in half. I could just run it from Access, but that's a lot of baggage.
The Photoshop reference just lists the param type as "Array (Points:Array (Array(x,y),...)" which is intended for VB6 or earlier.
At this point I'll try just about anything.