Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing/Editing an Excel Worksheet

Status
Not open for further replies.

SirLars

Technical User
Oct 24, 2000
47
CA
i am working on a vb program to enter information into an excel worksheet...

i have a function to retrieve a value from a specific cell

GetCellValue(strCellAddress)

and a subroutine to ENTER a value into a specific cell
PutCellValue(strCellAddress,strCellValue)

but i am having problems

how do i instantiate the worksheet? i have the workbook name and worksheet name as global variables w/in the project

dim goExcel as excel.application
dim goBook as excel.workbook
dim goSheet as excel.worksheet

set gosheet = new gobook(strfilename).worksheet(strWorksheetname)

it doesn't accept any of this at all?

any suggestions would be greatly appreciated
 
Set goExcel = GetObject("", "excel.application")
Set goBook = objexcel.Workbooks(strfilename)
Set goSheet = ActiveSheet

Then deal with range object:
Dim goRange as Excel.Range
Set goRange = goSheet.Range("a1", "a2") ' values to suit your app

You can then reference cells by:
goRange.Cells(xref,yref) = YourVariable 'xref and yref are offsets from start of range Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top