Excel e gli applicativi Microsoft Office Conoscere il nome di un grafico selezionato

Login Registrati
Stai vedendo 5 articoli - dal 1 a 5 (di 5 totali)
  • Autore
    Articoli
  • #2243 Score: 0 | Risposta

    ilFonta
    Partecipante
      Salve
      Vorrei venire a conoscenza del nome di un qualsiasi grafico che ho selezionato cliccandoci sopra.
      Ho scritto questa riga
      Dim chartName As String
      chartName = ActiveChart.Name
      ma invece di restituirmi il nome del grafico, che nel mio caso e' "Chart 4" mi da "Sheet1 Chart 4", ovvero comprende anche il nome del foglio in uso.
      Esiste un altro metodo per venire a conoscenza del nome del grafico?
      Grazie
      #2247 Score: 0 | Risposta

      Marius44
      Moderatore
        58 pts
        Ciao
        Prova con questa macro (scrive il nome nella col.J)
        Sub Nome()
        Dim x As Integer, i As Integer
        x = ActiveSheet.Shapes.Count
        For i = 1 To x
            Cells(i, 10) = ActiveSheet.Shapes(i).Name
        Next i
        End Sub

        Fai sapere. Ciao,
        Mario

        #2259 Score: 0 | Risposta

        ilFonta
        Partecipante
          Ciao Mario e grazie
          mi serve una cosa lievemente diversa
          L'ideale sarebbe se esistesse un metodo come ActiveShape (ma non esiste lo so) per poter fare
          chartName = ActiveSheet.ActiveShapes.Name
          Come ti ho detto esiste ActiveChart, ma mi restituisce il nome del foglio + quello del grafico
          Grazie
          #2269 Score: 0 | Risposta

          Marius44
          Moderatore
            58 pts
            Ciao
            Ma appunto per quello ti ho suggerito la macro!
            Se vuoi assegnare ad una variabile il nome del Grafico, basta sostituire a Cells(i,10) il nome della variabile (anche ChartName) ma facendo attenzione se si hanno diverse Shapes nel Foglio.
            Ciao,
            Mario
            #2272 Score: 0 | Risposta

            albatros54
            Moderatore
              89 pts

              Puo essere utile al fine di capire quale grafico è selezionato.

              Determining Whether a Chart Is
              Activated
              A common type of macro performs some manipulations on the active
              chart (the chart selected by a user). For example, a macro might
              change the chart's type, apply a style, add data labels, or export the
              chart to a graphics file.
              The question is how can your VBA code determine whether the user
              has actually selected a chart? By selecting a chart, I mean either
              activating a chart sheet or activating an embedded chart by clicking it.
              Your first inclination might be to check the TypeName property of the
              Selection, as in this expression:
              TypeName(Selection) = “Chart”
              In fact, this expression never evaluates to True. When a chart is
              activated, the actual selection will be an object within the Chart
              object. For example, the selection might be a Series object, a
              ChartTitle object, a Legend object, or a PlotArea object.
              The solution is to determine whether ActiveChart is Nothing. If so, a
              chart isn't active. The following code checks to ensure that a chart is
              active. If not, the user sees a message, and the procedure ends:
              If ActiveChart Is Nothing Then
              MsgBox “Select a chart.”
              Exit Sub
              Else
              ‘other code goes here
              End If
              You may find it convenient to use a VBA function procedure to
              determine whether a chart is activated. The ChartIsSelected function,
              which follows, returns True if a chart sheet is active or if an embedded
              chart is activated, but returns False if a chart isn't activated:
              Private Function ChartIsActivated() As Boolean
              ChartIsActivated = Not ActiveChart Is Nothing
              End Function

              Qual è il punto di avere gusti diversi, se non mostrare che i cervelli lavorano diversamente, che pensiamo diversamente?( Alan Turing)

            Login Registrati
            Stai vedendo 5 articoli - dal 1 a 5 (di 5 totali)
            Rispondi a: Conoscere il nome di un grafico selezionato
            Gli allegati sono permessi solo ad utenti REGISTRATI
            Le tue informazioni: