Subject: A little strange situation!!!
what do u want to draw, the below code may help u , i am uing the below code to draw pie chart and bar chart, but this is not for selected doc, it draw chart for all, u can do for selected doc by changing the code.regds
soma
Sub Initialize
Dim ws As New NotesSession
Dim NS As New NotesUIWorkspace
Dim db As NotesDatabase
Dim col As NotesDocumentCollection
Dim doc As Notesdocument
Dim yescount As Integer,nocount As Integer
Dim tracktest As String
Dim Choice As String
Dim LVal(1) As String
Dim view As notesview
Dim view1 As notesview
’ Dim doc As notesdocument
Dim doc1 As notesdocument
Dim CompanyName1 As Variant
Dim CompanyName2 As Variant
Set db = ws.currentdatabase
Set view = db.getview("(sbuview)")
Set view1 = db.getview("Master Revenue2")
'Give User Choice of chart type
LVal(0) = "Bar Chart"
LVal(1) = "Pie Chart"
Choice = NS.Prompt(Prompt_OKCancelList , "Chart Selection Box","Please Select a Chart","Pie Chart",LVal)
'Excel automation code. Written so we can display data in a Graph / pie chart.
Dim xlApp As Variant
Dim xlSheet As Variant
Dim xlob As Variant
Set xlApp = CreateObject("Excel.application")
xlApp.Visible=True
xlApp.Workbooks.add
'xlsheet.Activate
Set xlSheet = xlApp.Workbooks(1).Worksheets(1)
'''''
'add chart information
xlApp.Charts.add
Dim ourchart As Variant
Dim Chartchoice As Integer
Set ourchart = XlApp.Charts("Chart1")
If Choice = "Pie Chart" Then
'Chartchoice = -4102
Chartchoice = 5
’ Chartchoice = 71
'xlApp.ActiveWorkbook.ActiveChart.charttype= {-4102}
Else
ChartChoice = 51
’ ChartChoice = 60
End If
ourchart.chartType = Chartchoice
‘’’
Dim i
Dim k
Dim p
Dim l
Set doc = view.getfirstdocument
k =0
p =0
Do Until doc Is Nothing
k = k+1
Set doc = view.getnextdocument(doc)
Loop
Redim Preserve ctr(k)
Dim collection As notesdocumentcollection
Redim Preserve ptr(k)
Redim Preserve mtr(k)
Dim tot
l = 1
Set doc = view.getfirstdocument
Do Until doc Is Nothing
ctr(l) = Cstr(doc.sbu_x(0))+" " + Cstr(doc.subsbu_x(0))+" " + Cstr(doc.revenue_n(0))
ptr(l) =Cstr(doc.sbu_x(0))+ Cstr(doc.subsbu_x(0))
Set doc = view.getnextdocument(doc)
l= l+1
Loop
For i =1 To Ubound(ctr)
If i = 1 Then
m ="A"
Elseif i =2 Then
m="B"
Elseif i = 3 Then
m ="C"
Elseif i = 4 Then
m="D"
Elseif i = 5 Then
m="E"
Elseif i =6 Then
m ="F"
Elseif i = "7" Then
m="G"
Elseif i =8 Then
m ="H"
Elseif i = 9 Then
m="I"
Elseif i =10 Then
m ="J"
Elseif i = 11 Then
m ="K"
Elseif i = 12 Then
m ="L"
End If
xlSheet.Range(m+Cstr(1)).Value = ctr(i)
'xlSheet.Range (m.Value) = ctr(i)
Set collection = view1.GetAllDocumentsByKey(Cstr(ptr(i)), False)
If collection.count = 0 Then
xlSheet.Range("B" & Cstr(i)).Value = 0
Else
Set doc1 = collection.getfirstdocument
tot=0
Do Until doc1 Is Nothing
tot = tot+ Cint(doc1.rcombusi_x(0))
Set doc1 = collection.getnextdocument(doc1)
Loop
End If
xlSheet.Range(m+Cstr(2)).Value = tot
' ourchart.setsourcedata(xlSheet.Range("A1:B"+Cstr(i)))
Next
ourchart.setsourcedata(xlSheet.Range("A1:"+Cstr(m)+"2"))
’ xlApp.activechart.Axes(1).HasTitle = True
’ xlApp.activechart.Axes(2).HasTitle = True
With ourchart
.HasTitle = True
.ChartTitle.Characters.Text = "Tracking Chart Results"+Cstr(m)
.HasLegend = True
.ApplyDataLabels
' xlApp.activechart.Axes(1).AxisTitle.Characters.Text = "somasundaram"
'xlApp.activechart.Axes(2).AxisTitle.Characters.Text = "subramanian"
End With
'''
'Close our main references to Excel
Set xlSheet = Nothing
Set xlApp =Nothing
End Sub