programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel??
programmatically draw lines in excel?? programmatically draw lines in excel??
programmatically draw lines in excel??
Go Back  Xtreme Visual Basic Talk > > > programmatically draw lines in excel??


Reply
 
Thread Tools Display Modes
  #1  
Old 10-17-2007, 05:24 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Question programmatically draw lines in excel??


Hi There,

I must be going loopy!! I thought this was easy, just put some code in my excel class and 'bobs your uncle' its done!! but for the life of me I cannot find no where on the net that says how to do this, as well as other shapes, can it be done, or is it to difficult??

A shortcut to a tut, or handy hints would be great.

pig.
Reply With Quote
  #2  
Old 10-18-2007, 03:06 AM
DennisW's Avatar
DennisW DennisW is offline
Junior Contributor
 
Join Date: Mar 2006
Location: Östersund, Sweden
Posts: 268
Default

Hi,

Will the following snippet code get you in the right direction?

Code:
Dim xlApp As New Excel.Application Dim xlBook As Excel.Workbook = xlApp.Workbooks.Add Dim xlSheet As Excel.Worksheet = CType(xlBook.Worksheets(1), Excel.Worksheet) Dim xlShape As Excel.Shape With xlSheet.Range("B3:D10") xlShape = xlSheet.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, CSng(.Left), CSng(.Top), CSng(.Width), CSng(.Height)) End With With xlShape .ShapeStyle = Microsoft.Office.Core.MsoShapeStyleIndex.msoLineStylePreset10 'Add additional code to modify the added shape End With With xlApp .UserControl = True .Visible = True End With
__________________
Kind regards,
Dennis

.NET & Excel | 2nd edition PED | MVP
Reply With Quote
  #3  
Old 10-18-2007, 03:54 AM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

Hi DennisW,

Cheers!! thanks I've have a look later.

pig.
Reply With Quote
  #4  
Old 10-18-2007, 04:14 AM
DennisW's Avatar
DennisW DennisW is offline
Junior Contributor
 
Join Date: Mar 2006
Location: Östersund, Sweden
Posts: 268
Default

If we only want to add borders to a cell range then the following works:

Code:
Dim xlApp As New Excel.Application Dim xlBook As Excel.Workbook = xlApp.Workbooks.Add Dim xlSheet As Excel.Worksheet = CType(xlBook.Worksheets(1), Excel.Worksheet) Dim xlRange As Excel.Range = xlSheet.Range("H5:J15") With xlRange With .Borders(Excel.XlBordersIndex.xlEdgeTop) .ColorIndex = 0 .Weight = Excel.XlBorderWeight.xlThin .LineStyle = Excel.XlLineStyle.xlContinuous .TintAndShade = 0 End With With .Borders(Excel.XlBordersIndex.xlEdgeRight) .ColorIndex = 0 .Weight = Excel.XlBorderWeight.xlThin .LineStyle = Excel.XlLineStyle.xlContinuous End With With .Borders(Excel.XlBordersIndex.xlEdgeLeft) .ColorIndex = 0 .Weight = Excel.XlBorderWeight.xlThin .LineStyle = Excel.XlLineStyle.xlContinuous End With With .Borders(Excel.XlBordersIndex.xlEdgeBottom) .ColorIndex = 0 .Weight = Excel.XlBorderWeight.xlThin .LineStyle = Excel.XlLineStyle.xlContinuous End With With .Borders(Excel.XlBordersIndex.xlInsideVertical) .ColorIndex = 0 .Weight = Excel.XlBorderWeight.xlThin .LineStyle = Excel.XlLineStyle.xlContinuous End With With .Borders(Excel.XlBordersIndex.xlInsideHorizontal) .ColorIndex = 0 .Weight = Excel.XlBorderWeight.xlThin .LineStyle = Excel.XlLineStyle.xlContinuous End With End With With xlApp .UserControl = True .Visible = True End With
__________________
Kind regards,
Dennis

.NET & Excel | 2nd edition PED | MVP
Reply With Quote
  #5  
Old 10-18-2007, 03:45 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

Hi DennisW,

Thanks for your information but my class can already handle borders, I'm just to sure on lines etc, its for building a Sogg Chart 'Rail industry' talk, it does have another name but I just cannot remember it.

pig
Reply With Quote
  #6  
Old 10-18-2007, 04:21 PM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

even something like this seems to work

Code:
Dim rect2 As Excel.Shape = _ xlSheet.Shapes.AddLine(198.0#, 248.25, 456.0#, 378.0#) '(Microsoft.Office.Core.MsoAutoShapeType.msoShapeCube, 167.25, 124.5, 66.0#, 32.25)

not to sure how useful that will be.
Reply With Quote
  #7  
Old 10-19-2007, 02:19 AM
DennisW's Avatar
DennisW DennisW is offline
Junior Contributor
 
Join Date: Mar 2006
Location: Östersund, Sweden
Posts: 268
Default

Hi,

Could you pls tell me what a Sogg Chart 'Rail industry' is.
__________________
Kind regards,
Dennis

.NET & Excel | 2nd edition PED | MVP
Reply With Quote
  #8  
Old 10-19-2007, 04:21 AM
piggybank1974's Avatar
piggybank1974 piggybank1974 is offline
Ultimate Contributor
 
Join Date: Mar 2002
Location: weston-super-mare(UK)
Posts: 1,795
Default

I remember the name; a 'Time Change Diagram' same thing different name. basically a line represents a time for the first point to the last point.

the pig.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel?? programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel?? programmatically draw lines in excel??
programmatically draw lines in excel??
programmatically draw lines in excel??
 
programmatically draw lines in excel??
programmatically draw lines in excel??
 
-->