Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default I know selected picture is a shape but typename says is picture

Hi,

I am trying to move a shape that is selected to the left. Have the below code:

Sub Test()
Dim oSheet as workhseet
Dim oShape as Shape
Dim oObj as Object ' I don't know if the shape or something else is selected, so I get the object selected.
set oSheet = Application.ActiveSheet
oObj = Application.Selection
if TypetName(oObj) = "Picture" then
' Shape selected
set oShape = oObj ' Try to convert to oShape to access its properties. I get an error type mismatch here
oShape.left = oShape.left - 60
end if
End Sub

Thank you,

Carlos Lozano
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default I know selected picture is a shape but typename says is picture

Carlos,

Did you copy this routine exactly? If so, you have a typo he
"TypetName"

Stan Scott
New York City

"Carlos Lozano" wrote in message
...
Hi,

I am trying to move a shape that is selected to the left. Have the below

code:

Sub Test()
Dim oSheet as workhseet
Dim oShape as Shape
Dim oObj as Object ' I don't know if the shape or something else is

selected, so I get the object selected.
set oSheet = Application.ActiveSheet
oObj = Application.Selection
if TypetName(oObj) = "Picture" then
' Shape selected
set oShape = oObj ' Try to convert to oShape to access its

properties. I get an error type mismatch here
oShape.left = oShape.left - 60
end if
End Sub

Thank you,

Carlos Lozano



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default I know selected picture is a shape but typename says is picture

Hi Carlos,

In addition to the typo pointed out by Stan,

Dim oSheet as workhseet


should be

Dim oSheet as Worksheet

This version of your code worked for me:

Sub Test()
Dim oSheet As Worksheet
Dim oObj As Picture

Set oSheet = ActiveSheet
Set oObj = Selection
oObj.Left = oObj.Left - 60

End Sub

This version, where I move and resize the picture, also worked for me:
Sub Test2()
Dim oSheet As Worksheet
Dim oObj As ShapeRange

Set oSheet = ActiveSheet
Set oObj = Selection.ShapeRange
oObj.IncrementLeft 147.75
oObj.IncrementTop 11.25
oObj.ScaleWidth 0.9, msoFalse, msoScaleFromTopLeft
oObj.ScaleHeight 0.9, msoFalse, msoScaleFromTopLeft

End Sub


---
Regards,
Norman



"Carlos Lozano" wrote in message
...
Hi,

I am trying to move a shape that is selected to the left. Have the below

code:

Sub Test() Dim oShape as Shape
Dim oObj as Object ' I don't know if the shape or something else is

selected, so I get the object selected.
set oSheet = Application.ActiveSheet
oObj = Application.Selection
if TypetName(oObj) = "Picture" then
' Shape selected
set oShape = oObj ' Try to convert to oShape to access its

properties. I get an error type mismatch here
oShape.left = oShape.left - 60
end if
End Sub

Thank you,

Carlos Lozano



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default I know selected picture is a shape but typename says is pictur

Thank you Norman and Stan.

The typos are only in the posting, not in thereal code.

What helped me was the line:

Dim oObj as Object
Dim oImage as Picture
Set oImage = oOBj ' THIS IS VALID, Hurray!

This definition allows to convert the object to Image, so I was albe to access all its properties with no doubt about it and avoiding the trial and error time. I really needed the conversion as I don't know if the user selected a picture, cell, etc, I was not able to set it as Picture at the begining as it would crash if something else was selected.

Thank you,

Carlos Lozano


"Norman Jones" wrote:

Hi Carlos,

In addition to the typo pointed out by Stan,

Dim oSheet as workhseet


should be

Dim oSheet as Worksheet

This version of your code worked for me:

Sub Test()
Dim oSheet As Worksheet
Dim oObj As Picture

Set oSheet = ActiveSheet
Set oObj = Selection
oObj.Left = oObj.Left - 60

End Sub

This version, where I move and resize the picture, also worked for me:
Sub Test2()
Dim oSheet As Worksheet
Dim oObj As ShapeRange

Set oSheet = ActiveSheet
Set oObj = Selection.ShapeRange
oObj.IncrementLeft 147.75
oObj.IncrementTop 11.25
oObj.ScaleWidth 0.9, msoFalse, msoScaleFromTopLeft
oObj.ScaleHeight 0.9, msoFalse, msoScaleFromTopLeft

End Sub


---
Regards,
Norman



"Carlos Lozano" wrote in message
...
Hi,

I am trying to move a shape that is selected to the left. Have the below

code:

Sub Test() Dim oShape as Shape
Dim oObj as Object ' I don't know if the shape or something else is

selected, so I get the object selected.
set oSheet = Application.ActiveSheet
oObj = Application.Selection
if TypetName(oObj) = "Picture" then
' Shape selected
set oShape = oObj ' Try to convert to oShape to access its

properties. I get an error type mismatch here
oShape.left = oShape.left - 60
end if
End Sub

Thank you,

Carlos Lozano




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
Manually changing a picture (shape) name property ker_01 Excel Discussion (Misc queries) 4 April 3rd 23 07:01 PM
Connect a number to a picture bank and import that picture to exce Dennis Hedo Excel Discussion (Misc queries) 1 March 22nd 10 02:17 PM
Picture displayed when item selected in a different cell JB Bates[_2_] Excel Discussion (Misc queries) 2 November 4th 09 06:48 PM
how do I insert picture into cell so vlookup can return picture? ah Excel Worksheet Functions 1 May 1st 07 04:38 AM
insert a picture in to a comment but picture not save on hard disk Pablo Excel Discussion (Misc queries) 0 February 21st 07 03:48 PM


All times are GMT +1. The time now is 12:07 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"