PC Review


Reply
Thread Tools Rate Thread

borders in VBScript

 
 
mechif@gmail.com
Guest
Posts: n/a
 
      11th Jun 2008
Hi!
I created worksheets from a CSV file using VBScript (Excel 2003).
I want to put a border around the filled cells (UsedRange).
I recorded a macro to put full borders (top, bottom, right, left) and
tried to addapt it to my VBScript.

Where can I get a list of all the xl constants - because they are not
recognized in the VBScript ?
How do I write the code so the borders will work?
Thanks!
Mechi


Set objExcel =
CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Add
wsheetNum = 1
Set objSummarySheet = objWorkbook.Worksheets(wsheetNum)
objSummarySheet.Name = "Summary"
....
....
With
objSummarySheet.UsedRange.borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With objSummarySheet.UsedRange.borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With objSummarySheet.UsedRange.borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With objSummarySheet.UsedRange.borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With objSummarySheet.UsedRange.borders(xlInsideVertical)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With objSummarySheet.UsedRange.borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      11th Jun 2008
You can get constants form the Object Browser in VBA Excel

right click the VBA code window and select Object browser. Enter the
constant you are looking for like Borders and press binoculars to do a search.

Borders will be highlighted in the Bottom left pane. Click on Item in the
Right Pane. the on the bottom of the pane click on XlBordersIndex. You will
see each of the constants listed. If you press on one of the constants the
value will be displayed on the bottom of the pane.

"(E-Mail Removed)" wrote:

> Hi!
> I created worksheets from a CSV file using VBScript (Excel 2003).
> I want to put a border around the filled cells (UsedRange).
> I recorded a macro to put full borders (top, bottom, right, left) and
> tried to addapt it to my VBScript.
>
> Where can I get a list of all the xl constants - because they are not
> recognized in the VBScript ?
> How do I write the code so the borders will work?
> Thanks!
> Mechi
>
>
> Set objExcel =
> CreateObject("Excel.Application")
> Set objWorkbook = objExcel.Workbooks.Add
> wsheetNum = 1
> Set objSummarySheet = objWorkbook.Worksheets(wsheetNum)
> objSummarySheet.Name = "Summary"
> ....
> ....
> With
> objSummarySheet.UsedRange.borders(xlEdgeLeft)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> With objSummarySheet.UsedRange.borders(xlEdgeTop)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> With objSummarySheet.UsedRange.borders(xlEdgeBottom)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> With objSummarySheet.UsedRange.borders(xlEdgeRight)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> With objSummarySheet.UsedRange.borders(xlInsideVertical)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
> With objSummarySheet.UsedRange.borders(xlInsideHorizontal)
> .LineStyle = xlContinuous
> .Weight = xlThin
> .ColorIndex = xlAutomatic
> End With
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set a reference to Microsoft VBScript Regular Expressions(vbscript.dll) cate Microsoft Excel Programming 3 1st Dec 2009 03:07 PM
Unable to call a vbscript within a vbscript Karuna Microsoft Access VBA Modules 1 6th Oct 2008 02:12 PM
lines & colored table borders, shared borders, thumbnails Jan Microsoft Frontpage 2 30th Mar 2008 07:13 PM
How to format cell's borders by using VBSCript? htphuoc Microsoft Excel Programming 2 7th Jul 2006 08:00 AM
tables - green borders? blue borders? yikes DianaH Microsoft Frontpage 4 13th Oct 2005 09:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:15 PM.