E
eBob.com
I've learned that after inserting a picture into my spreadsheet (which I am
creating in a VB.Net program) I have to adjust it's size. So I recorded a
macro to so and ended up with the following:
Sub sizepic()
'
' sizepic Macro
' Macro recorded 8/27/2007 by John Smith
'
'
ActiveSheet.Shapes("Picture 4").Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 110.25
Selection.ShapeRange.Width = 65.25
Selection.ShapeRange.Rotation = 0#
End Sub
I think that ActiveSheet here corresponds to "objSheet" in my program (Dim
objSheet As Excel._Worksheet). But when I translate this to this VB.Net
statement ...
objSheet.Shapes("Picture " + XLRow.ToString).select()
the VS IDE complains that: "Interface 'Excel.Shapes' cannot be indexed
because it has no default property."
So I scratch my head, fumble around, and find that the following (which
seemed reasonable at the time!) compiles and builds without error:
objSheet.Shapes().select("picture " + XLRow.ToString)
But it results in runtime error: Public member 'select' on type 'Shapes' not
found.
The remainder of the code which I have derived from the above is ...
objSheet.Shapes.lockaspectratio = msotrue
objSheet.Shapes.height = 110.25
objSheet.Shapes.width = 65.25
That compiles and builds OK (except that I have to determine the value of
"msotrue") but I sort of expect runtime errors. I can't use
objSheet.Selection because the IDE says that 'Selection' is not a member of
Excel._Worksheet).
So ... any further assistance you guys can provide would be much
appreciated. Thanks, Bob
creating in a VB.Net program) I have to adjust it's size. So I recorded a
macro to so and ended up with the following:
Sub sizepic()
'
' sizepic Macro
' Macro recorded 8/27/2007 by John Smith
'
'
ActiveSheet.Shapes("Picture 4").Select
Selection.ShapeRange.LockAspectRatio = msoTrue
Selection.ShapeRange.Height = 110.25
Selection.ShapeRange.Width = 65.25
Selection.ShapeRange.Rotation = 0#
End Sub
I think that ActiveSheet here corresponds to "objSheet" in my program (Dim
objSheet As Excel._Worksheet). But when I translate this to this VB.Net
statement ...
objSheet.Shapes("Picture " + XLRow.ToString).select()
the VS IDE complains that: "Interface 'Excel.Shapes' cannot be indexed
because it has no default property."
So I scratch my head, fumble around, and find that the following (which
seemed reasonable at the time!) compiles and builds without error:
objSheet.Shapes().select("picture " + XLRow.ToString)
But it results in runtime error: Public member 'select' on type 'Shapes' not
found.
The remainder of the code which I have derived from the above is ...
objSheet.Shapes.lockaspectratio = msotrue
objSheet.Shapes.height = 110.25
objSheet.Shapes.width = 65.25
That compiles and builds OK (except that I have to determine the value of
"msotrue") but I sort of expect runtime errors. I can't use
objSheet.Selection because the IDE says that 'Selection' is not a member of
Excel._Worksheet).
So ... any further assistance you guys can provide would be much
appreciated. Thanks, Bob