CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2000
    Posts
    5

    Creating Excel Spreadsheets

    How would I create an Excel spreadsheet and save it to a file within VB?

    Thanks,

    COrey


  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Creating Excel Spreadsheets

    Dim ApExcel As Object 'To open Excel

    Set ApExcel = CreateObject("Excel.application") 'Creates an object
    ApExcel.Visible = True ' So you can see Excel
    ApExcel.Workbooks.Add 'Adds a new book.
    ApExcel.cells(1, 1).Formula = "HELLO" 'Add Text to a Cell
    'You can use the line above, changing coordenates to go to any
    'cell and you can also add Formulas
    ApExcel.Range("A1:Z1").BORDERS.Color = RGB(0, 0, 0) 'Use it to
    'change the borders.
    ApExcel.Columns("A:AY").EntireColumn.AutoFit 'To adjust the
    'column's width.
    ApExcel.Range("A:Z").Select 'To establish a selection
    ApExcel.Selection.NumberFormat = "0" 'Adding different formats


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Creating Excel Spreadsheets

    To save
    xlapp.activeworksheet.SaveAs "C:\Whatever"



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured