Visualizzazione dei risultati da 1 a 2 su 2

Discussione: [VB6] grafici

  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2001
    Messaggi
    193

    [VB6] grafici

    Vi è mai capitato di incontrare questo errore:

    ActiveChart.Location method 'location' of object '_ chart' failed

    Sto cercando di fare un grafico con excel vi posto il codice

    Public Function CreateGraph(ByVal sFilterType As String, ByVal strDelimiter As String, ByVal strTitles As String, ByVal strCellVals As String, _
    Optional ByVal iChartType As String, Optional ByVal strExportPath As String, _
    Optional ByVal strCellVals2 As Variant, Optional ByVal strCellVals3 As Variant, Optional ByVal strGroupTitles As Variant) As String

    Dim ctChartType As Long
    Dim lngCellStart As Long
    Dim lCol As New Collection
    Dim i As Integer
    Dim lngCols As Long
    Dim NextFile As String
    Dim bRet As Boolean

    '# these values should be false, or true if in de-bug mode
    '# and you wish to see the Excel sheet being prepared
    '# Debugging while visible will not work from the web server

    xlApp.Interactive = False
    xlApp.Visible = False

    '# assign the cell titles
    '# Set the titles of the groups if selected.
    '# Place in the first column of the excel sheet.

    If Not IsMissing(strGroupTitles) Then
    '# unparse the group titles string
    Set lCol = ParsedString(strGroupTitles, strDelimiter)
    For i = 1 To lCol.Count ' Set up n repetitions to the colection object.
    xlSheet.Cells(i + 1, 1).Value = lCol(i)
    Next i
    lngCellStart = 1
    End If

    If Not IsMissing(strTitles) Then
    '# unparse the titles string
    Set lCol = ParsedString(strTitles, strDelimiter)
    For i = 1 To lCol.Count ' Set up n repetitions to the colection object.
    xlSheet.Cells(1, i + 1).Value = lCol(i)
    Next i
    End If

    '# assign the cells values

    If Not IsMissing(strCellVals) Then
    lngCols = 2
    '# unparse the titles string
    Set lCol = ParsedString(strCellVals, strDelimiter)
    For i = 1 To lCol.Count ' Set up n repetitions to the colection object.
    xlSheet.Cells(lngCols, i + 1).Value = lCol(i)
    Next i
    End If

    If Not IsMissing(strCellVals2) Then
    lngCols = lngCols + 1
    Set lCol = ParsedString(strCellVals2, strDelimiter)
    For i = 1 To lCol.Count ' Set up n repetitions to the colection object.
    xlSheet.Cells(lngCols, i + 1).Value = lCol(i)
    Next i
    End If

    If Not IsMissing(strCellVals3) Then
    lngCols = lngCols + 1
    Set lCol = ParsedString(strCellVals3, strDelimiter)
    For i = 1 To lCol.Count ' Set up n repetitions to the colection object.
    xlSheet.Cells(lngCols, i + 1).Value = lCol(i)
    Next i
    End If

    '# select the range to be used by the chart
    xlSheet.Range(xlSheet.Cells(1, lngCellStart), xlSheet.Cells(lngCols, lCol.Count + 1)).Select

    '# determine what chart type was requested
    If Not iChartType = 0 Then
    Select Case CInt(iChartType)
    Case 1
    ctChartType = xl3DColumn
    Case 2
    ctChartType = xl3DBar
    Case 4
    ctChartType = xl3DLine
    Case 3
    ctChartType = xl3DPie
    End Select
    Else: ctChartType = xl3DColumn
    End If

    '# generate the chart - cheat by activating the chart wizard
    xlApp.Charts.Add.ChartWizard gallery:=ctChartType, _
    Format:=4, _
    Title:="Title", categoryTitle:="Cat Title", valueTitle:="Val Title"

    '# assign a parent sheet to the chart

    xlApp.ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"

    bRet = IIf(Not IsMissing(strGroupTitles), xlApp.ActiveChart.HasLegend, Not xlApp.ActiveChart.HasLegend)

    '#assign a backdrop for the chart
    xlApp.ActiveChart.ChartArea.Fill.PresetTextured PresetTexture:=20

    NextFile = strExportPath & CStr(FreeFile) & "." & sFilterType
    '# export the chart
    xlApp.ActiveChart.Export NextFile, FilterName:=sFilterType

    '# trick the app into thinking it dosn't need to save the workbook
    xlBook.Saved = True
    '# and close it
    xlBook.Close

    '# quit the xlapp only if we created it here
    If Not xlActive Then xlApp.Quit

    '# pass out the name of the generated graph
    CreateGraph = NextFile

    End Function


    Ciao Martina

  2. #2
    Utente di HTML.it L'avatar di Kahm
    Registrato dal
    Dec 2004
    residenza
    Rome
    Messaggi
    3,574
    visto ceh io ho excel ma ...
    faresti bene ad indicare precisamente (tipo mettere in grassetto) esattamente dove è l'errore
    e che errore ti da


    forse...in questo modo sare sti piu' chiara
    NN vi diro mai chi sono in realta,
    tutti i miei 3D sono orfani, non insistete per farmi rispondere ai 3D aperti da me

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.