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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access and Excel

Status
Not open for further replies.

ogri

Programmer
Sep 26, 2000
74
GB
Hi

I am trying to write an Access application which will take incoming data from Excel spreadsheets, and eventually output the data in the same format. For this I need to write some VBA code to populate an Excel spreadsheet.

Using the help this seems easy, and I can get Access to kick off Excel and generate a spreadsheet, then save it. However I cannot get Access to populate any of the fields. The relevant code is as below:-

Set MyXL = GetObject("c:\temp\010101.XLS")
If Err.Number = 432 Then
Err.Clear ' Clear Err object in case error occurred.
Set MyXL = CreateObject("Excel.Sheet")
newSheet = True
End If

MyXL.Application.Visible = True
MyXL.Parent.Windows(1).Visible = True

For xPos = 1 To 20
For yPos = 1 To 20
MyXL.Cells(xPos, yPos).Value = Str$(xPos) + Str$(yPos)
Err.Clear
Next
Next
If newSheet Then
MyXL.SaveAs "c:\temp\010100.xls"
End If
Set MyXL = Nothing ' Release reference to the

This is resulting error number 438 "Object does not support this propert or method". However, I cannot see what I have done wrong (hopefully just a silly typo....)

All the best

Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top