VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Format Data Series patterns in Excel chart from VB Line and Marker options Rate Topic: -----

#1 Student_101  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 12-January 09


Dream Kudos: 0

Share |

Format Data Series patterns in Excel chart from VB

Post icon  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??
Was This Post Helpful? 0
  • +
  • -


#2 thava  Icon User is offline

  • D.I.C Lover
  • Icon

Reputation: 103
  • Posts: 1,223
  • Joined: 17-April 07


Dream Kudos: 150

Re: Format Data Series patterns in Excel chart from VB

Posted 23 January 2009 - 04:13 PM

HOW WOULD YOU IMPORT YOUR DATA TO EXCEL ?

IF YOU USE CELLS .VALUE METHOD THEN USE THE SAME WAY TO FORMAT IT IF OTHER THAN THIS PLS POST YOUR CODE HERE TO SOLVE YOUR PROBLEM
Was This Post Helpful? 0
  • +
  • -

#3 Student_101  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 12-January 09


Dream Kudos: 0

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:

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


Was This Post Helpful? 0
  • +
  • -

#4 thava  Icon User is offline

  • D.I.C Lover
  • Icon

Reputation: 103
  • Posts: 1,223
  • Joined: 17-April 07


Dream Kudos: 150

Re: Format Data Series patterns in Excel chart from VB

Posted 26 January 2009 - 05:59 PM

just try this link

http://forums.devx.c...p/t-167791.html
Was This Post Helpful? 0
  • +
  • -

#5 Student_101  Icon User is offline

  • New D.I.C Head
  • Pip

Reputation: 1
  • View blog
  • Posts: 17
  • Joined: 12-January 09


Dream Kudos: 0

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.
Was This Post Helpful? 0
  • +
  • -

#6 thava  Icon User is offline

  • D.I.C Lover
  • Icon

Reputation: 103
  • Posts: 1,223
  • Joined: 17-April 07


Dream Kudos: 150

Re: Format Data Series patterns in Excel chart from VB

Posted 27 January 2009 - 01:33 PM

with pleasure

if you try then we should always help for you
if you make a single step towards the solution then we should surely show a way for you
Was This Post Helpful? 1
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users