Page 1 of 1
Format Data Series patterns in Excel chart from VB Line and Marker options
#1
Format Data Series patterns in Excel chart from VB
Posted 23 January 2009 - 08:35 AM
Hi everyone,
This might be something simple,
I have exported a graph from my MSFlex grid in VB6 to Excel, everything works fine.
I just need to format the patterns under the data series to a different line and marker foreground color, style, and etc.
Any suggestions??
This might be something simple,
I have exported a graph from my MSFlex grid in VB6 to Excel, everything works fine.
I just need to format the patterns under the data series to a different line and marker foreground color, style, and etc.
Any suggestions??
#3
Re: Format Data Series patterns in Excel chart from VB
Posted 26 January 2009 - 05:48 AM
Hi,
The data export to excel is fine, and it also plots the graph.
I need to format the data series patterns, such as the line and the markers, their colour, their style, foreground color..
this is my coode:
The data export to excel is fine, and it also plots the graph.
I need to format the data series patterns, such as the line and the markers, their colour, their style, foreground color..
this is my coode:
Dim cmd_Results As New ADODB.Command
Dim RS_Results As New ADODB.Recordset
Dim objExcelA As Excel.Application
Dim objExcelW As Excel.Workbook
Dim objExcelDATA As Excel.Worksheet 'Issues Work Sheet
Dim objExcelCHART As Excel.Worksheet 'Stirs Work Sheet
Dim objExcelCI As Excel.Chart
Dim cho As Excel.ChartObject
Dim Row As Long
Dim chgtype As Long
Dim newcell As String
With cmd_Results
.ActiveConnection = m_Conn
.CommandText = sSql
.CommandType = adCmdText
End With
With RS_Results
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmd_Results
End With
Set grd_result.DataSource = RS_Results
Call SizeColumns
Set objExcelA = New Excel.Application
Set objExcelW = objExcelA.Workbooks.Add
'Set objWorksheet to the remaining worksheet.
Set objExcelDATA = objExcelA.ActiveSheet
objExcelDATA.Name = "Data"
For P = 0 To grd_result.Rows - 1
For Q = 0 To grd_result.Cols - 1
grd_result.Col = Q
grd_result.Row = P
newcell = Chr(Q + 65) & P + 1
'xl.Worksheets("Sheet1").Range(newCell).Value = grd_result.Text
objExcelDATA.Range(newcell).Value = grd_result.Text
Next
Next
objExcelW.Charts.Add
Set objExcelCI = objExcelW.ActiveChart
objExcelCI.Activate
objExcelCI.Name = "Please Edit Title as needed"
objExcelCI.SetSourceData objExcelDATA.Range("B2:C" & grd_result.Rows)
objExcelCI.ChartType = xlXYScatterLines
objExcelCI.HasTitle = True
objExcelCI.ChartTitle.Text = objExcelCI.Name
objExcelCI.Legend.Position = xlLegendPositionBottom
With objExcelCI
.PlotArea.Interior.ColorIndex = 2
.HasLegend = False
With .Axes(xlCategory)
.HasTitle = True
.AxisTitle.Caption = "Date (MM/DD/YYYY)"
End With
With .Axes(xlValue)
.HasTitle = True
.AxisTitle.Caption = "Value (PPM)"
' Const xlMarkerStyleCircle = 8
' Const xlDash = -4115 '(&HFFFFEFED)
' Const xlLineMarkers = 65 '(&H41)
' Const xlFill = 5
End With
End With
objExcelA.Visible = True
objExcelA.UserControl = True
objExcelA.WindowState = xlMaximized
objExcelA.DisplayAlerts = False
Set objExcelA = Nothing
Set objExcelW = Nothing
Set objExcelDATA = Nothing
Set objExcelCHART = Nothing
Set objExcelCI = Nothing
RS_Results.Close
Set RS_Results = Nothing
#4
Re: Format Data Series patterns in Excel chart from VB
Posted 26 January 2009 - 05:59 PM
#5
Re: Format Data Series patterns in Excel chart from VB
Posted 27 January 2009 - 07:09 AM
Thanks a lot for your help Thava !
I tried the Macro thing in excel, started the macro, formatted the chart according to the requirements, and got the code.
Then with some minor editions I was able to work the code in VB
Everything works fine now.
Thanks once again.
I tried the Macro thing in excel, started the macro, formatted the chart according to the requirements, and got the code.
Then with some minor editions I was able to work the code in VB
Everything works fine now.
Thanks once again.
Page 1 of 1

Ask A New Question
Reply





MultiQuote




|