Hallo Forum,
ich habe vor kurzem den unten angefügten Quellcode im Netz (SearchDomino) gefunden.
Ich habe nun versucht, diese Funktion mal einzubauen um eine Auswertungsseite für unseren Chef aufzubereiten.
Leider laufe ich auf einen Fehler in der Zeile: (Fehlermeldung siehe Anhang)
.Location xlLocationAsObject, ChartName 'move chart to worksheet
Hier der gesamte code den ich verwende:
The following code sample puts some sample data into an EXCEL Sheet and creates a chart in the currently opened Notes document.
The doc must have a field ("Chart"), richtext
The DECLARATION SECTION holds some constants for different ChartStyles.
Sub Click(Source As Button)
On Error Goto errhandler
Dim session As New notessession
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As notesdocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim xlApp As Variant
Dim oWorkbook As Variant
Dim ChartName As String ' Eigene Ergänzung
Dim msoFalse As Boolean ' Eigene Ergänzung
Dim msoScaleFromTopLeft As Boolean ' Eigene Ergänzung
msoFalse = True ' Eigene Ergänzung
msoScaleFromTopLeft = True ' Eigene Ergänzung
Set uidoc = workspace.CurrentDocument
Set doc = uidoc.Document
uidoc.EditMode = True
ChartName = "Test"
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = False 'set to invisible
Set oWorkbook = xlApp.Workbooks 'handle to Workbook
oWorkbook.Add
'/* BEGIN OF SAMPLE DATA
xlApp.cells(1,2) = "100"
xlApp.cells(2,2) = "140"
xlApp.cells(3,2) = "1000"
xlApp.cells(4,2) = "100"
xlApp.cells(5,2) = "1900"
xlApp.cells(6,2) = "1340"
xlApp.cells(1,1) = "Uli"
xlApp.cells(2,1) = "Kathleen"
xlApp.cells(3,1) = "Freitz"
xlApp.cells(4,1) = "Wombat"
xlApp.cells(5,1) = "Eddi"
xlApp.cells(6,1) = "Hannelore"
'/* END OF SAMPLE DATA
xlApp.Range("A1:B6").Select 'select the data rows and create a chart
xlApp.Charts.Add
Dim xlChartType As Long ' Eigene Ergänzung
Dim xlLocationAsObject As Long ' Eigene Ergänzung
xlChartType = xl3DColumn 'set chart type; see DECLARATION SECTION
xlLocationAsObject = 2
With xlApp.ActiveWorkbook.ActiveChart
.Name = ChartName$
.HasTitle = True
.HasLegend = False
.ChartTitle.Text = "Test: "
.ChartType = xlChartType
.PlotArea.Interior.ColorIndex = "0"
.Location xlLocationAsObject, ChartName 'move chart to worksheet 'Fehlerzeile!
End With
xlApp.ActiveSheet.ChartObjects("Chart 1").Activate
xlApp.ActiveChart.ChartArea.Select 'select chart
xlApp.ActiveChart.ChartArea.Copy 'copy to clipboard
xlApp.ActiveSheet.Shapes("Chart 1").ScaleWidth 0.85, msoFalse, msoScaleFromTopLeft 'change chart dimensions
xlApp.ActiveSheet.Shapes("Chart 1").ScaleHeight 1.24, msoFalse, msoScaleFromTopLeft
xlApp.ActiveChart.ChartGroups(1).GapWidth = 10 'reduce width between columns
Call uidoc.GotoField( "Chart" ) 'select rt field chart in current doc
Call uidoc.Paste 'paste clipboard contents into field
Call doc.Save( True, True )
xlApp.ActiveWorkbook.saved = True ' closes EXCEL without prompting
Call xlApp.Workbooks.close
Call xlApp.quit
Exit Sub
errhandler:
xlApp.DisplayAlerts = False
Call xlApp.Quit( )
Set xlApp = Nothing
Msgbox "Error in Library/Agent: xxxxxx Error: " & Error & " (" & Err & ") in line: " & Erl
Exit Sub
End Sub
'/Paste the following into the OPTION-SECTION
Option Declare
'/Paste the following into the DECLARATION-SECTION
Const xl3DArea=-4098
Const xl3DAreaStacked=78
Const xl3DAreaStacked100=79
Const xl3DBar=-4099
Const xl3DBarClustered=60
Const xl3DBarStacked=61
Const xlLine=4
Const xlLineMarkers=65
Const xlLineMarkersStacked=66
Const xlLineMarkersStacked100=67
Const xlLineStacked=63
Const xlLineStacked100=64
Const xl3DBarStacked100=62
Const xl3DColumn=-4100
Const xl3DColumnClustered=54
Const xl3DColumnStacked=55
Const xl3DColumnStacked100=56
Const xl3DLine=-4101
Const xl3DPie=-4102
Const xl3DPieExploded=70
Const xl3DSurface=-4103
Const xlAreaStacked=76
Const xlAreaStacked100=77
Const xlBarClustered=57
Const xlBarOfPie=71
Const xlBarStacked=58
Const xlBarStacked100=59
Const xlBubble=15
Const xlBubble3DEffect=87
Const xlColumnStacked=52
Const xlColumnStacked100=53
Const xlConeBarClustered=102
Const xlConeBarStacked=103
Const xlConeBarStacked100=104
Const xlConeCol=105
Const xlConeColClustered=99
Const xlConeColStacked=100
Const xlConeColStacked100=101
Const xlCylinderBarClustered=95
Const xlCylinderBarStacked=96
Const xlCylinderBarStacked100=97
Const xlCylinderCol=98
Const xlCylinderColClustered=92
Const xlCylinderColStacked=93
Const xlCylinderColStacked100=94
Hat jemand eine Idee wo das Problem begraben ist?
Systemumgebung:
Notes 9.01 deutsch
Office 2010
Grüße
Bernd