Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.computer > #10532

Re: OT: How find Excel Picture number

From Robert Baer <robertbaer@localnet.com>
Newsgroups alt.computer
Subject Re: OT: How find Excel Picture number
References <DAxMB.4$zb.2@fx44.iad> <otu96r$koq$1@dont-email.me> <P0zMB.1$Vy2.0@fx07.iad> <otueq3$17st$1@gioia.aioe.org>
Message-ID <FhQMB.120$5H2.108@fx30.iad> (permalink)
Date 2017-11-08 19:51 -0800

Show all headers | View raw


Paul wrote:
> Robert Baer wrote:
>> Paul wrote:
>>> Robert Baer wrote:
>>>>   In Excel, I was able to find the names/picture numbers for the first
>>>> two shapes by trial and error.
>>>>   Then i added a third shape and unable to find the number; up to
>>>> Number 35 and am tired of this BS.
>>>>   Is there a way of finding it so i can use it?
>>>>   As in ActiveSheet.Shapes(<name>).Select ?
>>>>
>>>>   Thanks.
>>>
>>> Would something from this help ?
>>>
>>> https://msdn.microsoft.com/en-us/vba/excel-vba/articles/shapes-range-property-excel
>>>
>> * Don't know.
>>   I do not remember how i created the first 2 "shapes"; the third one
>> is a copy/paste and manual resize.
>>
>>>
>>>
>>> There's a .range operator. Would that cover
>>> the top-most array index ?
>>   Array? What array? Does Excel automatically create an array and put
>> these in it?
>>   Ditto for "range.
>>
>>   I think i found that ActiveSheet.Shapes(1).Select exists, and no other.
>>   I know that ActiveSheet.Shapes("Picture 6").Select works, and that
>> ActiveSheet.Shapes("Picture 11").Select also works.
>>   What s irking is that anything else creates an error and the Excel
>> OnError does NOT detect that error.
>>   If it did,a loop counting from 1 to (say) 999 MIGHT find that third
>> item.
>>
>>   That first "example" looks like one is creating an array arShapes,
>> but where in the hell did those names come from, what does each
>> element look like (do not trust names), and where did they come from?
>>
>>   I suppose i could have 3 GIF files, and Insert From File to
>> successive cells; note no "range" command used, no array foo, and
>> certainly no names.
>>
>>   This business is less clear than oily mud.
>> **
>>   My relevant notes in the macro is:
>> 'With myDocument.Shapes.BuildFreeform(msoEditingCorner, 260, 150)
>> '    .AddNodes msoSegmentLine, msoEditingAuto, 400, 150
>> '    .AddNodes msoSegmentLine, msoEditingAuto, 400, 180
>> '    .AddNodes msoSegmentLine, msoEditingAuto, 260, 180
>> '    .AddNodes msoSegmentLine, msoEditingAuto, 260, 150
>> '    .ConvertToShape
>> 'End With
>> '   Have rectangle where i want the text
>> ' Select that new shape...
>> '    'iobj.1    'for output display
>> '    'iobj.2    'vertical jumper
>> '    'iobj.3    'horizontal jumper
>> '    'iobj.4    'smaller jumper  <---i ASSUME this is added shape
>> '    so.. iobj.5 is new box
>> '    ActiveSheet.Shapes(5).Select    'yes, have box
>>
>> '*Do NOT need BuildFreeform
>> Labell = Range("J1").Text + "V"
>> Set sh = ActiveSheet.Shapes.AddShape _
>> (msoShapeRectangle, 260, 180, 150, 60)
>> sh.Fill.ForeColor.RGB = RGB(255, 255, 255)
>> sh.Fill.Visible = msoTrue   'False has same effect
>> sh.TextFrame.Characters.Text = Labell
>> sh.TextFrame.Characters.Font.Size = 36
>> sh.TextFrame.Characters.Font.Name = "Arial Black"
>> sh.TextFrame.Characters.Font.Bold = True
>> sh.TextFrame.Characters.Font.Color = vbRed
>>
>> 'With myDocument.Shapes.AddLine(260, 140, 120, 60).Line
>> '    .DashStyle = msoLineDashDotDot
>> '    .ForeColor.RGB = RGB(50, 0, 128)
>> 'End With
>>
>> sh.Line.DashStyle = msoLineDashDotDot
>> sh.Line.ForeColor.RGB = RGB(50, 0, 128)
>> '''
>>   So,the third shape was made differently.
>>   Above code partly stolen and partly via brute force from other
>> stolen code.
>>   Certainly NOT from "examples" which essentially do not exist.
>>
>>   Thanks.
>>
>>
>>>
>>>     Paul
>>
>
> Here's another idea.
>
> https://stackoverflow.com/questions/32255992/how-do-i-list-all-existing-objects-in-an-excel-workbook-to-a-text-file
>
>
>     Paul
   The article was a bit confusing, but gave me some ideas.
   And my in-program documentation concerning iobj.<number> which 
realistically does not exist.

   There is absolutely no way to access these objects directly, much 
less in order.

   After a lot of messing around, this was only reliable result:

  pic = 1 ' or object but NOT picture
  ' 1=vert; 2=horiz; 3=frame; 4=small; 5=title
' found nature of each given shape by incremental use of this "filter"
  For Each iobj In ActiveSheet.Shapes    'DrawingObjects
   iobj.Select
   If pic = 2 Then
     Selection.Copy  'get horizontal jumper
   End If
   pic = pic + 1
  Next iobj

   For removal of stuff/objects added by program:

Klear:
     'Erase added stuff for next try
      ' 1=vert; 2=horiz; 3=frame; 4=small; 5=title
  num = 1
  For Each iobj In ActiveSheet.Shapes    'DrawingObjects
   iobj.Select
   If num > 4 Then
    iobj.Delete
   End If
   num = num + 1
  Next iobj
  Close

   Note my objects 1-4 are reference for copy/paste operations.

Back to alt.computer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-07 22:35 -0800
  Re: OT: How find Excel Picture number Paul <nospam@needed.invalid> - 2017-11-08 01:45 -0500
    Re: OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-08 00:13 -0800
      Re: OT: How find Excel Picture number Paul <nospam@needed.invalid> - 2017-11-08 03:21 -0500
        Re: OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-08 19:51 -0800
  Re: OT: How find Excel Picture number Jeroen Belleman <jeroen@nospam.please> - 2017-11-08 09:12 +0100
    Re: OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-08 19:23 -0800
  Re: OT: How find Excel Picture number Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-11-08 08:12 +0000
    Re: OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-08 19:41 -0800
      Re: OT: How find Excel Picture number Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-11-09 08:33 +0000
        Re: OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-09 09:55 -0800
          Re: OT: How find Excel Picture number Paul <nospam@needed.invalid> - 2017-11-09 14:12 -0500
            Re: OT: How find Excel Picture number Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-11-09 20:20 +0000
            Re: OT: How find Excel Picture number Robert Baer <robertbaer@localnet.com> - 2017-11-10 17:15 -0800
              Re: OT: How find Excel Picture number Martin Brown <'''newspam'''@nezumi.demon.co.uk> - 2017-11-13 16:32 +0000

csiph-web