Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jim_chan
Specialist
Specialist

Function only some objects in macro script

Untitled.png

Hi experts,

I would like to create a button that will restore ONLY the objects in the red box. Is anyone can help me.. the CH... are the object ID for each objects

With this macro script is restore all of the object include left hand side list box:

sub MaximizeAll

Objects = ActiveDocument.ActiveSheet.GetSheetObjects

For j = lBound(Objects) To uBound(Objects)

set obj = Objects(j)

obj.Restore

next

end sub

But i just want restore the object in the red box only. Is anyone can help me?

Thank you very much

1 Solution

Accepted Solutions
settu_periasamy
Master III
Master III

if it is less objects, you can try like this..

sub MaximizeAll ()
      ActiveDocument.GetSheetObject("CH01").Restore
      ActiveDocument.GetSheetObject("CH02").Restore

      ActiveDocument.GetSheetObject("CH03").Restore
end sub

View solution in original post

5 Replies
settu_periasamy
Master III
Master III

if it is less objects, you can try like this..

sub MaximizeAll ()
      ActiveDocument.GetSheetObject("CH01").Restore
      ActiveDocument.GetSheetObject("CH02").Restore

      ActiveDocument.GetSheetObject("CH03").Restore
end sub

tamilarasu
Champion
Champion

Hello Jim,


You can also use button actions to minimize and maximize the objects like below. Sample attached for your reference.

Capture.PNG

jim_chan
Specialist
Specialist
Author

Thanks settu,

it works for me...thanks you very much

Kushal_Chawda

Another way is to list out the  Object ID which are needed to restore  in inline table of the script

Objects:

LOAD * inline [

ObjectID

CH01

CH02

CH03 ];


you can take this object ID field in listbox on front end and note the objectID of listbox


Now use the macro like below


sub MaximizeAll

set LB = ActiveDocument.GetSheetObject("LB01")

boxvalues=LB.GetPossibleValues

for i = lbound(boxvalues) to ubound(boxvalues)

set obj = Objects(i)

obj.Restore

next

end sub

settu_periasamy
Master III
Master III

Even you can try this too.. with less code..

sub MaximizeAll ()

SheetObj=Array("CH01","CH02","CH03")  ' Chart ID's here
for i=0 to UBound(SheetObj)
ActiveDocument.GetSheetObject(SheetObj(i)).Restore
Next

end sub