0 Replies Latest reply: Mar 1, 2013 5:25 AM by Micael Leal RSS

    Access Sheet & Object VBS

      Hello,

       

      I was looking around how to switch between sheets and how to access individual object.

       

      Hope this might help a bit.

       

      Sub Loop_Sheets_And_Objects

          'loop through all sheets

          for i = 0 to ActiveDocument.NoOfSheets - 1

              'Switching between Sheets

              'ActiveDocument.Sheets(ActiveDocument.Sheets(i).GetProperties.Name).Activate

              'msgbox(ActiveDocument.Sheets(i).GetProperties.Name)

              set s=ActiveDocument.Sheets(ActiveDocument.Sheets(i).GetProperties.Name)

              orignumber=s.NoOfSheetObjects

              for j=0 to orignumber-1

                   rem ** get unique object ID for given object on sheet **

                   set so = s.SheetObjects(j)

                   'msgbox(so.GetObjectId)

                   id = so.GetObjectId

                   'msgbox("ID = " & id)

                   'Access on specific Object Id

                   IF id="Document\T_DAILY_SUM" THEN

                       msgbox("Access on a table")

                   END IF

              next

          next   

      End Sub