A little strange situation!

Firstly I thanks to all people who replied to my topics posted before.

Now I have no problems with agents but still have problems about drawing graph or charting. I think, I couldn’t explain what I need exactly.

I downloaded the softwares mentioned in my replies but they are not sutisfied me. They are very good applications but so complex for my customers. The most of Companies here don’t have any IT department so and nobody can use computer very much, we still have a big problem about using computers in Turkey, so I have to let them to draw graphs, just like in MS Excel, using action or hotspot button they will select the data and according to those data script will draw the graph. I tried to do this but I couldn’t find any way and time is running out I have no much time, pleaase somebody help me in this chaotic condition.

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

Subject: RE: A little strange situation!!!

First thanks for your attention. I copied the code you gave and run it but it gives an error at the line below and does not continoue

'add chart information

xlApp.Charts.add

Dim ourchart As Variant

Dim Chartchoice As Integer

at the line

Set ourchart = xlApp.Charts(“Chart1”)

it gives an error as

OLE: Automation object error

If Choice = "Pie Chart" Then

'Chartchoice = -4102

	Chartchoice = 5

Subject: RE: A little strange situation!!!

hi, u can’t directly use this, u have to modify the code , the error is due to the below code

" ChartChoice = 51 " use charttype=60 instaed of 51. try to modify ur code.

regds

soma

Subject: RE: A little strange situation!!!

i will modify the code but first i have to see what results the code give. But i cant pass over the code line Set ourchart = xlApp.Charts(“Chart1”)

code gives an error when executing line above. now the problem is at that line. if i can execute the script entirely i will modify where it needs…

regds

Ozcan