-
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
-
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. :(
-
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
-
Thank you SO much! You guys are life savers! I can finally wrap this thing up now! :-)
Thanks again!
Ray