Group:  Microsoft Access ยป microsoft.public.access.interopoledde
Thread: Opening Excel spreadsheet from Access does not refresh data

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Opening Excel spreadsheet from Access does not refresh data
"Fjordur" <someone[ at ]microsoft.com> 18.09.2006 13:36:58
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,
--
Fjordur


Re: Opening Excel spreadsheet from Access does not refresh data
John Nurick <j.mapSoN.nurick[ at ]dial.pipex.com> 19.09.2006 20:59:32
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.

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net