Formulas of Linked Pictures in Groups

L

Legacy 356664

Guest
Hi there,

I am trying to retrieve the formula from all linked pictures so that I can turn on/off updates using defined names.
This is working fine, except for when the linked picture is part of a group.

I have tried
For Each Pic In ActiveSheet.Pictures
Select Case Pic.Type
Case msoGroup
For groupIndex = 1 To Pic.GroupItems.Count
array(x) = Pic.GroupItems(groupIndex).Formula
x = x + 1
Next groupIndex
End Select
Next Pic

But this returns an empty string (in arr(x))

Any suggestions? Thanks for your help
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Try something like this...

Code:
[color=darkblue]Option[/color] [color=darkblue]Explicit[/color]

[color=darkblue]Sub[/color] GetFormulasFromLinkedPictures()

    [color=darkblue]Dim[/color] aFormulas() [color=darkblue]As[/color] [color=darkblue]String[/color]
    [color=darkblue]Dim[/color] oShape [color=darkblue]As[/color] Shape
    [color=darkblue]Dim[/color] oGroupItem [color=darkblue]As[/color] Shape
    [color=darkblue]Dim[/color] PicCnt [color=darkblue]As[/color] [color=darkblue]Long[/color]
    
    PicCnt = 0
    [color=darkblue]For[/color] [color=darkblue]Each[/color] oShape [color=darkblue]In[/color] ActiveSheet.Shapes
        [color=darkblue]Select[/color] [color=darkblue]Case[/color] oShape.Type
            [color=darkblue]Case[/color] msoPicture
                PicCnt = PicCnt + 1
                [color=darkblue]ReDim[/color] [color=darkblue]Preserve[/color] aFormulas(1 [color=darkblue]To[/color] PicCnt)
                aFormulas(PicCnt) = oShape.DrawingObject.Formula
            [color=darkblue]Case[/color] msoGroup
                [color=darkblue]For[/color] [color=darkblue]Each[/color] oGroupItem [color=darkblue]In[/color] oShape.GroupItems
                    [color=darkblue]If[/color] oGroupItem.Type = msoPicture [color=darkblue]Then[/color]
                        PicCnt = PicCnt + 1
                        [color=darkblue]ReDim[/color] [color=darkblue]Preserve[/color] aFormulas(1 [color=darkblue]To[/color] PicCnt)
                        aFormulas(PicCnt) = oGroupItem.DrawingObject.Formula
                    [color=darkblue]End[/color] [color=darkblue]If[/color]
                [color=darkblue]Next[/color] oGroupItem
        [color=darkblue]End[/color] [color=darkblue]Select[/color]
    [color=darkblue]Next[/color] oShape
    
    [color=darkblue]If[/color] PicCnt > 0 [color=darkblue]Then[/color]
        [color=green]'Do something with the formulas in the array aFormulas()[/color]
    [color=darkblue]Else[/color]
        MsgBox "No pictures exist.", vbInformation
    [color=darkblue]End[/color] [color=darkblue]If[/color]
    
[color=darkblue]End[/color] [color=darkblue]Sub[/color]

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,216,731
Messages
6,132,391
Members
449,725
Latest member
Enero1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top