Results 1 to 4 of 4

Thread: Populating an Existing Spreadsheet from VB

  1. #1
    Guest
    I'm working on a work Attendance program that stores (random-access text file) hours worked, vacation/sick leave taken, etc. I have an existing time sheet (Timesheet.xls) that I want to populate from this program. Every news post and help file I have found so far explain how to create a new, blank spreadsheet, but I haven't found anything that explains how to work with an existing one. Basically, I need to enter the Employee's name into at R6C1, and Hours worked at R11C1:R11C34. Can anyone give me a clue or point me in the right direction?

    Thanks,

    Ray

  2. #2
    Guest
    Ray,

    Ok don't have the code in front of me, but ya have to create an Excel object and a Worksheet object.

    Ok there are two ways of opening a spreadsheet, one is CreateObject, the other is...and here l forget. But basically you attach the open xls sheet, assign the worksheet object to the worksheet ya want, then simply populate whatever cells ya want.

    Email me at [email protected], and l will email back a project showing how to do this. Sorry, but at this site am working on a Universe application, and don't have vb loaded.

  3. #3
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    Here's an example:

    Private Sub cmdLoadEmUp_Click()

    Set xlIn = CreateObject("Excel.Application")
    xlIn.Workbooks.Open "Path and Name"
    'xlIn.Visible = True
    xlIn.Worksheets(WorksheetName).Cells(Row, Column) = value
    ' Repeat until all cells updated
    xlIn.ActiveWorkbook.Close SaveChanges:=True
    xlIn.Quit
    Set xlIn = Nothing

    End Sub

  4. #4
    Guest

    Talking

    Thank you SO much! You guys are life savers! I can finally wrap this thing up now! :-)

    Thanks again!

    Ray

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