Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
I am so new I squeek
I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
The easiest way with Excel/VBA is to record a macro (ToolsMacroRecord New
Macro) and see the generated code. Whilst this code is generally not the most efficient, it gives you a starting point to see the required syntax/objects to use. NickHK "wbntravis" wrote in message ... I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Thanks Nick ! That helped show of some of the properties!
( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Hit the wrong key and the prev message posted prematurely.
continue: Here is how 2003 Excel shows I selected the object: ActiveSheet.Shapes("Tree").Select I have more than one "tree" in other cells. I would like to give the trees different names so I can modify only that object Ie: move it... or assign a rnd macro to it. I have read help exhaustedly... thanks again! "wbntravis" wrote: Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Something like this ?
Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
continued: hit the wrong key again
I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
I just used that shape, as I didn't waht you meant by "tree". However, try
this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Nick!
We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Yesterday, that code worked for me, but today I get that same error. OK, try
this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#11
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
HEY NICK You did it! When I first ran it I thought it was not working. Only to find it created these real tiny little trees across the second row. I was estatic. Nick, know that through this process I have learned a lot and there is much to experiment on... so I learn even more. A mere thank you is not enough for all your work. I do thank you... and blessings to your family. Know from what you taught me, I am able to test and experiment with other things and I will learn at a faster rate! Thanks again Travis "NickHK" wrote: Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#12
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Now you just to get them where you actually want them.
Good luck. NickHK "wbntravis" wrote in message ... HEY NICK You did it! When I first ran it I thought it was not working. Only to find it created these real tiny little trees across the second row. I was estatic. Nick, know that through this process I have learned a lot and there is much to experiment on... so I learn even more. A mere thank you is not enough for all your work. I do thank you... and blessings to your family. Know from what you taught me, I am able to test and experiment with other things and I will learn at a faster rate! Thanks again Travis "NickHK" wrote: Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#13
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Hi Nick,
That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#14
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Thanks Peter T
It works just fine here. I only needed the routine once to load the drawing and the real issue was trying to get a name to an autoshape which I found missing in every help file I explored. This whole issue was a big lesson in itself... This whole exercise taught me many things that now make a lot of sense when i read the help files. Nick was also showing me how to load a regular photo o/s of excel as well. In the actual application I found a bizarre happening where the "trees" drawing were named but when I asked excel to select a certain tree, the order was not the same when I copied them over to the application. One by one I sorted the 10 "trees" by the name based on excel's .select method. I am wondering now how I can change tree_10 to another name. (or any tree name) This is another exercise in itself. I do not mind changing the trees drawings by name, one by one as I am not sure what name I will give them anyway. In the game, I am writing, the trees have powers, ( given to it by a macro) which affects the characters. "Peter T" wrote: Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#15
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
I am wondering now how I can change tree_10 to another name.
(or any tree name) This is another exercise in itself. Sub Test() Dim nResult As Long nResult = RenameShape("Tree_10", "Tree_20", ActiveSheet) If nResult = 1 Then MsgBox "A shape already exists with new name" ElseIf nResult = 2 Then MsgBox "No shape exists with old name" End If End Sub Function RenameShape(sOld As String, sNew As String, _ Optional ws As Worksheet) As Long Dim shp As Shape If ws Is Nothing Then Set ws = ActiveSheet ' assumes not a chart sheet End If On Error Resume Next 'ensure no shape exists with new name 'and a shape does exist with old name Set shp = ws.Shapes(sNew) If Not shp Is Nothing Then RenameShape = 1 Else Set shp = ws.Shapes(sOld) If Not shp Is Nothing Then shp.Name = sNew Else RenameShape = 2 End If End If End Function Regards, Peter T "wbntravis" wrote in message ... Thanks Peter T It works just fine here. I only needed the routine once to load the drawing and the real issue was trying to get a name to an autoshape which I found missing in every help file I explored. This whole issue was a big lesson in itself... This whole exercise taught me many things that now make a lot of sense when i read the help files. Nick was also showing me how to load a regular photo o/s of excel as well. In the actual application I found a bizarre happening where the "trees" drawing were named but when I asked excel to select a certain tree, the order was not the same when I copied them over to the application. One by one I sorted the 10 "trees" by the name based on excel's .select method. I am wondering now how I can change tree_10 to another name. (or any tree name) This is another exercise in itself. I do not mind changing the trees drawings by name, one by one as I am not sure what name I will give them anyway. In the game, I am writing, the trees have powers, ( given to it by a macro) which affects the characters. "Peter T" wrote: Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#16
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Peter,
Thanks for the clarification. It did seem strange, as I had assumed that a picture was a Picture. Any idea how you tell a .wmf is not a Picture ? NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#17
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Peter,
Also, the code using ActiveSheet.Pictures.Insert(TREEFILE) worked on the day I posted it, as I tested it, but failed the next day when the OP said it failed. Weird. NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#18
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Hi Nick,
I don't fully understand wmf's (Windows Meta File). They seem to be either a vector drawing (not a picture), or can support an embedded raster image (a picture). I guess there must be something in the header file that determines what it is. As for testing if a wmf is a drawing or a picture once loaded, and if already referenced as a Shape - myShape.Type, 13 (msoPicture) or 1 (msoAutoShape) TypeName(myShape.DrawingObject), "Picture" or "Rectangle" or Brute force Dim pic as Picture On error resume next Set pic = myShape.DrawingObject or Set pic = myShape.Parent.Pictures(myShape.Name) ' assumes no punctuation in name If not pic is Nothing Then The nice thing about wmf drawings is you can reformat fill and line formats. Regards, Peter T "NickHK" wrote in message ... Peter, Thanks for the clarification. It did seem strange, as I had assumed that a picture was a Picture. Any idea how you tell a .wmf is not a Picture ? NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#19
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Indeed strange why it originally worked for you. When I tried your code with
that particular wmf it loaded fine then failed attempting to set the 'As Picture' reference. However I can set 'As Picture' with other types of wmf. Any possibility you might have removed an Error handler before posting, or any difference in XL version between testings. Regards, Peter T "NickHK" wrote in message ... Peter, Also, the code using ActiveSheet.Pictures.Insert(TREEFILE) worked on the day I posted it, as I tested it, but failed the next day when the OP said it failed. Weird. NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#20
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Peter,
Yes, metafiles are good for many applications. Just that I was surprised that a wmf was not considered a picture although it is obviously a format that Excel supports. I can insert it using InsertPictureFrom File however the assignment to a Picture variable fails. Other (non-AutoShape) wmf behave as expected. One of things I guess. It's not vital to mean, just a curiosity. NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, I don't fully understand wmf's (Windows Meta File). They seem to be either a vector drawing (not a picture), or can support an embedded raster image (a picture). I guess there must be something in the header file that determines what it is. As for testing if a wmf is a drawing or a picture once loaded, and if already referenced as a Shape - myShape.Type, 13 (msoPicture) or 1 (msoAutoShape) TypeName(myShape.DrawingObject), "Picture" or "Rectangle" or Brute force Dim pic as Picture On error resume next Set pic = myShape.DrawingObject or Set pic = myShape.Parent.Pictures(myShape.Name) ' assumes no punctuation in name If not pic is Nothing Then The nice thing about wmf drawings is you can reformat fill and line formats. Regards, Peter T "NickHK" wrote in message ... Peter, Thanks for the clarification. It did seem strange, as I had assumed that a picture was a Picture. Any idea how you tell a .wmf is not a Picture ? NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#21
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
Peter,
No, once I found the OP's required wmf, set the path in code, quick test to run that code, saw results and posted the code. Next day OP said failed, I tested again and, yep, failed. NickHK "Peter T" <peter_t@discussions wrote in message ... Indeed strange why it originally worked for you. When I tried your code with that particular wmf it loaded fine then failed attempting to set the 'As Picture' reference. However I can set 'As Picture' with other types of wmf. Any possibility you might have removed an Error handler before posting, or any difference in XL version between testings. Regards, Peter T "NickHK" wrote in message ... Peter, Also, the code using ActiveSheet.Pictures.Insert(TREEFILE) worked on the day I posted it, as I tested it, but failed the next day when the OP said it failed. Weird. NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#22
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
I just wanted to step in here and thank both of you, Nick and Peter for
all this great info. I never knew my one question would lead to so many posts. I read every one and I am learning. Thanks again! Travis "NickHK" wrote: Peter, No, once I found the OP's required wmf, set the path in code, quick test to run that code, saw results and posted the code. Next day OP said failed, I tested again and, yep, failed. NickHK "Peter T" <peter_t@discussions wrote in message ... Indeed strange why it originally worked for you. When I tried your code with that particular wmf it loaded fine then failed attempting to set the 'As Picture' reference. However I can set 'As Picture' with other types of wmf. Any possibility you might have removed an Error handler before posting, or any difference in XL version between testings. Regards, Peter T "NickHK" wrote in message ... Peter, Also, the code using ActiveSheet.Pictures.Insert(TREEFILE) worked on the day I posted it, as I tested it, but failed the next day when the OP said it failed. Weird. NickHK "Peter T" <peter_t@discussions wrote in message ... Hi Nick, That clipart wmf is not a Picture but an autoshape type of drawing with a yellow handle , so it setting it to an object declared 'As Picture' would fail. If the OP wants to load the wmf to original size could use your Insert method but declare NewTree As Object (or As Rectangle for this particular wmf type but less safe), or to size to needs on load use the Shape method. Regards, Peter T "NickHK" wrote in message ... Yesterday, that code worked for me, but today I get that same error. OK, try this, with the more modern Shapes collection: Private Sub CommandButton3_Click() Dim NewTree As Shape Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddPicture(TREEFILE, False, True, 10, 10, 10, 10) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Nick! We are almost there! You have been a wonderful help. Using a picture was correct and this routine I will reuse over and over again as what I am making - involves pictures. The sub worked fine for one tree before the compiler gave me an error 13 type mismatch. Please see where I remarked the code. Sub createTrees() Dim NewTree As Picture Dim i As Long 'my folder string.... Nick... You were right my folder was different. Const TREEFILE As String = "C:\Program Files\Microsoft Office\MEDIA\OFFICE11\AUTOSHAP\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) '****** The above line is where I get the type mismatch error 13 With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next **** Like I said it worked fine to create 1 tree. The tree image is up on my screen. After the first tree it goes into the type mismatch error. "NickHK" wrote: I just used that shape, as I didn't waht you meant by "tree". However, try this. You may have to change the path depending on you installation/version of Office. Private Sub CommandButton1_Click() Dim NewTree As Picture Dim i As Long Const TREEFILE As String = "C:\Program Files\Microsoft Office\Office XP\media\office10\AutoShap\BD18253_.wmf" For i = 1 To 10 Set NewTree = ActiveSheet.Pictures.Insert(TREEFILE) With NewTree .Left = Cells(10, i * 2).Left .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... continued: hit the wrong key again I looked up "msoShapeFlowchartPredefinedProcess" to see what that joy was all about but neither online of offline help wanted to give me anything. Trust me, we I get this down I will name a tree after you. Please dont roll your eyes- haha wbnTravis "wbntravis" wrote: You are so close! That code produced 10 rectangles here with two smaller rectangles off to one side for each object that was produced above the worksheet. (which made ugly looking trees ) There were 10 of these ufos (unitendified flying objects ) to confirm the for i = 10 so I did a little digging and found a tree was an autoshape (not sure if that makes a difference) and the name according to excel is BD18235.wmf (not sure if that makes a difference. Your coding is interesting and the minute I saw it I almost fell over to see the .name = Tree & i could do it. I looked up "NickHK" wrote: Something like this ? Private Sub CommandButton1_Click() Dim NewTree As Shape Dim i As Long For i = 1 To 10 Set NewTree = ActiveSheet.Shapes.AddShape(msoShapeFlowchartPrede finedProcess, 20 * i, 202.5, 174.75, 84.75) With NewTree .Name = "Tree_" & i End With Next End Sub NickHK "wbntravis" wrote in message ... Thanks Nick ! That helped show of some of the properties! ( I did not think of it because I had a macro on the tree shape already.) Since I have more than one tree shape i was kinda looking for a name property... so I could move different "name"d trees from one cell to another based on the players movement. Here is how 2003 Excel indicates I selected the tree. "wbntravis" wrote: I am so new I squeek I need to put shapes/ autoshapes and small photos in a cell. Like cell( B:2) How does one control the autoshape or photo properites using VBA? |
#23
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing the properties of a Shape/ AutoShape within a cell
I looked up some info on WMF's and EMF's once. From what I recall WMF
(Windows meta file) is a 16-bit version and EMF (enhanced meta file) is the 32-bit version. So use EMF where possible. The "meta" in the name is because the file format contains both vector and raster information in the file. That allows you to resize them and still have the image and text render nicely. It's a nice format for working with pictures within Office apps. [Disclaimer: I'm working off a fuzzy memory here, so I may not be 100% correct, but I'm pretty sure I got the gist of it.] Nicholas Hebb BreezeTree Software http://www.breezetree.com |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Changing Autoshape properties using formulas only | Excel Discussion (Misc queries) | |||
help needed trying to find autoshape/shape name | Excel Programming | |||
Bug? AutoShape position properties incorrect | Excel Programming | |||
Cell changing it's properties | New Users to Excel | |||
How to stop Excel from changing the cell properties? | Excel Discussion (Misc queries) |