Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default SCripting Border in Excel

I am writing a script to populate an excel speadsheet.

All works ok until I try and but borders around the results.

The snipet of code below is how I have tried to create the borders but with
ne results.

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}
with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeRight))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeTop))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeBottom))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlInsideHorizontal))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlInsideVertical))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

The problem appears to be with the Range statement.
Can anyone over advise?

Regards

Kevin


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default SCripting Border in Excel

Kevin,

I think you're missing the leading dots for the lines of code inside the
with statement. For example:

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
.LineStyle = xlContinuous;
.Weight = xlThick;
.ColorIndex = xlAutomatic;
}

Also, you can use the BorderAround method to put borders around the range.
You'll end up with shorter code. For example, this VBA code would do
something similar to what you're trying to do:

Sheet1.Range(Cells(1, 2), Cells(2, 6)).BorderAround xlContinuous,
xlThick, xlColorIndexAutomatic
With Sheet1.Range(Cells(1, 2), Cells(2, 6)).Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
With Sheet1.Range(Cells(1, 2), Cells(2, 6)).Borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With



--
Hope that helps.

Vergel Adriano


"KevinF" wrote:

I am writing a script to populate an excel speadsheet.

All works ok until I try and but borders around the results.

The snipet of code below is how I have tried to create the borders but with
ne results.

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}
with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeRight))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeTop))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeBottom))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlInsideHorizontal))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlInsideVertical))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

The problem appears to be with the Range statement.
Can anyone over advise?

Regards

Kevin


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default SCripting Border in Excel

The cells() inside the report.range() portion are unqualified. If the code is
in a general module, then those cells() refer to the activesheet.

If the code is under a worksheet, then they belong to the sheet that owns the
code--and I'm guessing that isn't Report.

I'd use:

with Report
with .Range(.Cells(ExcelRow,2),.Cells(EndRow,6)).Border s(xlEdgeLeft)
.....

or maybe simpler:
with Report.Cells(ExcelRow,2).resize(1,5).Borders(xlEdg eLeft)

(and no need for those surrounding ()'s either.)

KevinF wrote:

I am writing a script to populate an excel speadsheet.

All works ok until I try and but borders around the results.

The snipet of code below is how I have tried to create the borders but with
ne results.

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}
with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeRight))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeLeft))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with (Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeTop))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlEdgeBottom))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlInsideHorizontal))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

with
(Report.Range(Cells(ExcelRow,2),Cells(EndRow,6)).B orders(xlInsideVertical))
{
LineStyle = xlContinuous;
Weight = xlThick;
ColorIndex = xlAutomatic;
}

The problem appears to be with the Range statement.
Can anyone over advise?

Regards

Kevin


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel Dashboards Without VBA Scripting? binar[_2_] Charts and Charting in Excel 2 March 17th 09 03:58 PM
Excel Dashboard without VBA Scripting? binar[_2_] Excel Discussion (Misc queries) 0 March 17th 09 03:21 AM
VBA scripting in Excel Len Excel Programming 5 April 27th 06 04:06 AM
AVAYA CMS Scripting through Excel VBA Maxi[_2_] Excel Programming 5 March 11th 06 07:33 PM
is excel by itself enough to do scripting? gee at excel Excel Programming 1 October 14th 04 09:03 PM


All times are GMT +1. The time now is 06:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"