6 Replies Latest reply: Oct 10, 2013 10:34 AM by Corinna Theiß RSS

    Change object fonts by action

    Corinna Theiß


      Hi All,

       

      I have to provide a report with the possibility to switch all object's font and font size by a button.

      I thought of using some variables - and an related action, unfortunately, it does not seem to be possible to use variables for the font.

       

      Does anyone of you got an idea how to provide such functionality?

       

      Thank you !

        • Re: Change object fonts by action
          Clever Anjos

          Using macros, you can do what you want

          I´ve extracted the code below from APIguide.qvw

          rem  ** set random fonts modifications in all expression **

          rem  ** cells in all pivot tables on active sheet.      **

          Objects = ActiveDocument.ActiveSheet.GetSheetObjects

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

            If Objects(i).GetObjectType = 10 Then  'pivot tables

                set Pivot = Objects(i)

                set y = Pivot.GetProperties

                set e = y.ExpressionVisuals

                for k = 0 to e.Count-1

                  set f = e.Item (k)

                set v = f.CellVariations (0)

                  v.SizeMod = Rnd() * 5 - 2 - 0.5

                  v.StyleMod = Rnd() * 8 - 0.5          

                  v.TotalSizeMod = Rnd() * 5 - 2 - 0.5

                  v.TotalStyleMod = Rnd() * 8 - 0.5          

                next

                y.TableProperties.StyleNumber = -1  'set as custom style

                Pivot.SetProperties (y)

              end if

          next

          • Re: Change object fonts by action
            Corinna Theiß

            Thanks Anjos for the hint

             

            Anyway, I found this one in the APIGuide, which works fine:

             

            (Class SheetObject, Member SetFont)

             

            rem ** increase fontsize for all objects on active sheet by 1 point **

            set sh = ActiveDocument.ActiveSheet

            for i = 0 to sh.NoOfSheetObjects-1

                set obj = sh.SheetObjects(i)

                fnt = obj.GetFrameDef.Font

                fnt.PointSize1000 = fnt.PointSize1000 + 1000

                obj.SetFont fnt

            next

             

            unfortunately, it does not work for Objects placed in a container - any hint for that?