Hi Fjordur,
Ignore the message advising an upgrade to "Access 2004". There's no such product, and the motive of the poster seems likely to be malign.
I can't see anything obviously wrong with your code, but there could easily be a issue with Access talking to Excel while Excel is trying to retrieve data from Access.
Set a breakpoint on the Function OpenExcelFile line. When you step through the code line by line, does it work as you'd expect?
If so, it's likely there's a timing issue, and a short pause (maybe two or three seconds) after calling GetObject() may fix it.
On Mon, 18 Sep 2006 15:36:58 +0200, "Fjordur" <someone[ at ]microsoft.com> wrote:
[Quoted Text] >Hi, >I have a spreadsheet with a sheet that's linked to a query in my database >with automatic refresh on open. I also have a switchboard in the database >item that starts the following code to open the spreadsheet: > Function OpenExcelFile(strPathToFile As String) > Dim objXL As Object > On Error Resume Next > 'Set objXL = GetObject(, "Excel.Application") > Set objXL = GetObject(strPathToFile) > objXL.Application.Visible = True > objXL.Parent.Windows(1).Visible = True > End Function >It opens OK but the sheet is blank and XL is frozen until I go back to >Access, do nothing there, then go back to XL; then the spreadsheet refreshes >its data. >Of course I want the spreadsheet to open and refresh without the users >having to switch back to Access then to XL. >What's wrong or missing with the code above? >Thanks for help,
-- John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
|