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
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