Refresh an Excel page

janz

Registered User.
Local time
Today, 16:39
Joined
Jan 25, 2008
Messages
44
Hi, ever run into this problem/challenge?

I create some tables in Access, all kind of good calculations etc.
Then I link the outcome tables in an excel sheet over differnt pages in differnt pivot tables.
From the program I give a refresh as follows.
Where I supply the exact location of the file in a string.

Function Exsel(drIp As String)

Dim objXL, objWb, objR As Object ' Excel object variables
Dim Wscript As Object
Dim Title, text, tmp, i, j, name
Set objXL = CreateObject("Excel.Application")
objXL.Visible = True ' show window
' Load the Excel file from the script's folder
Set objWb = objXL.WorkBooks.Open(drIp)
objWb.RefreshAll

'close it all
objWb.Save
objWb.Close
Set objWb = Nothing
objXL.Quit ' Quit Excel
Set objXL = Nothing

End function

I found the base for this code on the forum however I now run into the following issue and used it in differnt occasions (trouble free)

However if I run the code on my multi page excel workbook, page one updates fine however page two does not properly refresh and page 3 seems to refersh again as it should be.

In other words.
If I open the sheet after running the code and I give a manual refresh
on page 1 I see no change. If I do it on page 2 I see a change and on page 3 there is no change.

Checking the changes on page 2 I find that after the manual referesh the data is correct.

Does any body have an idea what I'm doing wrong or what I could do differnt to not run into this issue??

JanZ
 
Re-reading my threar it just dawned on me that on page 2 the created pivot table is based upon the one of page 1. So maybe I had to refresh twice for the second table to react on the first.

And Yes Bingo it worked.

Still would be interested to be able to get a better solution in code. Just in case.
 

Users who are viewing this thread

Back
Top Bottom