Excel

hobbes2103

Active member
Joined
Jul 10, 2003
Messages
43
I have the following code to write into an existing Excel file :

Dim xlApp As Excel.Application
Dim xlbook As Excel.Workbook
Dim xlsheet As Excel.Worksheet

xlapp = New Excel.Application
xlbook = xlApp.Workbooks.Open("C:\MyFile.xls")

xlsheet = xlApp.Sheets(1)
xlsheet.Name = "Ma Feuille Excel"
xlsheet.Range("A1").Value = "Bienvenue"

Now I would like to do things such as drawing a frame on the cell, or changing the font or size of the text...
How do i do that?
:confused:
 
Try something like this:

(Theres no intellisense on this so its trial and error)

Code:
xlsheet.Cells(1, "A").Interior.Font = fnt
xlsheet.Cells(1, "A").Interior.Pattern = xlPatternGray25

The font is a guess, but the pattern works. Try using Interior.border for the frame and see what happens then.
 
What about :

Code:
        an example
        With oSheet.Range("A1", "D1")
            .Font.Bold = True
            .VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
        End With


        oRange = oSheet.Range(("A2", "D2")
        oRange.Orientation = 38
        oRange.WrapText = True
        oRange.Interior.ColorIndex = 36
        
        With oRange.Borders(Excel.XlBordersIndex.xlEdgeBottom)
            .LineStyle = Excel.XlLineStyle.xlDouble
            .Weight = Excel.XlBorderWeight.xlThick
        End With

        etc....
 
The easiest way to learn Office automation is by recording a macro and viewing the macros code. There are some actions w/c arent recorded by macros though but I think your specific problem should be covered.
 
Back
Top