PDA

Click to See Complete Forum and Search --> : Excel Q


QWERTY
Dec 1st, 1999, 02:04 AM
Can anyone give me an example (very simple one) on how to run excel, create a border around cell (1,1) and add some text to it (let's say "QWERTY")? I hope I'll be able to figure out the rest of what I have to do.

Thanks in advance

P.S. I have done that in VBA, is there a possibility to kind of copy the code into VB?

------------------
Visual Basic Programmer (at least I want to be one)
------------------
PolComSoft
You will hear a lot about it.



[This message has been edited by QWERTY (edited 12-01-1999).]

Al Smith
Dec 1st, 1999, 07:30 AM
Hi,
I don't know if this is exactly what you're looking for, but:
I find that when using VB to populate an Excel spreadsheet that the actual formatting of the spreadsheet is easier with an Excel macro. I add the data to the "raw" spreadsheet and then have VB call a macro for the formatting.
For example the VB program might perform the following:

xlSheet.Range("A2").Select
xlSheet.ActiveCell.Value = "QWERTY"

It would then call an Excel macro. (Excel 97)

With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = 1
End With

If you wanted to place a border around a block of cells, the range can be selected with the following macro.

ActiveCell.SpecialCells(xlLastCell).Select
r = "A2:L" & Trim(Str(ActiveCell.Row))
Range(r).Select

Al.

Manish
Dec 1st, 1999, 04:39 PM
dim objexcel as excel.application
dim objsheet as excel.worksheet
dim objrange as excel.range

set objexcel=new excel.application
objExcel.Workbooks.Add
Set objSheet = objExcel.Workbooks(1).Worksheets(1)
For j = 1 To 10
objSheet.Cells(1, j ) = "A"
Next j
'Format Report Data

Set objRange = objSheet.Range("A1","A10")
objRange.Select
With objRange
.Font.Name = "Ariel"
.Font.Size = 8
.Font.Bold = False
.Borders(xlEdgeBottom).LineStyle = xlContinuous
.Borders(xlEdgeLeft).LineStyle = xlContinuous
.Borders(xlEdgeRight).LineStyle = xlContinuous
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlInsideVertical).LineStyle = xlContinuous
end with

here is the sample code it will fill character a in the excel sheet and define header for this.....

Thanx Manish