Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Requesting Help (yes again) Translating a Macro into VB.Net Code

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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 236
Default Requesting Help (yes again) Translating a Macro into VB.Net Code

When you run the recorded macro, sizepic(), "Picture 4" already
exists, your only selecting it.

It looks like your code might work if you know for certain
XLRow.ToString() is 4 and from within C++ you're opening the Workbook
that has a "Picture 4" Shape.

If you are creating the Workbook dynamically then the problem is that
you don't have a shape object of name "Picture " + XLRow.ToString() .

Supposing you have added it then the problem is that you used a
barebones API to create the Shape and the Shape doesn't yet know it's
supposed to be a Picture.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Translating Erika Excel Discussion (Misc queries) 0 June 6th 08 03:13 PM
Translating formulas Cameron Excel Discussion (Misc queries) 9 August 3rd 06 11:43 AM
translating formulas Luc Benninger[_2_] Excel Programming 11 March 4th 05 04:52 PM
Requesting Help Scooterdog Excel Worksheet Functions 2 November 10th 04 06:18 PM
Overflow when translating from C++ HELP!! hunting Excel Programming 6 April 24th 04 08:18 PM


All times are GMT +1. The time now is 11:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"