Results 1 to 3 of 3

Thread: Excel Q

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    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).]

  2. #2
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    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.

  3. #3
    Lively Member
    Join Date
    Apr 1999
    Location
    India
    Posts
    73

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width