Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Problems with RefreshAll method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
GrahamBaines - 27 Nov 2007 11:50 GMT
Hi,

I've been writing a bit of code to automate the opening, refreshing of
external data, saving and closing of spreadsheets. I'm having problems which
I think are associated with the speed of the refesh. The workbook opens fine
but when I run the code I get a warning which states:- "This action will
cancel a pending data refresh command. Cancel?".

The code I'm running is:-

Private Sub CommandButton1_Click()

   Application.Workbooks.Open ("X:\ Stats 2007.xls")

   ActiveWorkbook.RefreshAll

   ActiveWorkbook.Save

   ActiveWorkbook.Close

End Sub

I tried disabling the messages using:-

"Application.DisplayAlerts = False"

That stopped the message and the workbook opened and closed fine, but the
refresh didn't save. I tried putting a wait statement into the code to pause
the 'save' command until the refresh has had time to complete, but that had
no effect. I inserted an 'On Error' statement and forced the code to loop
back to the 'save' command until it had completed, but again to no avail.

I find it inconceivable that it isn't possible to open, refresh, save and
close a workbook from another workbook using vba as it seems to me to be a
sensible and logical thing to want to do, but at present it's defeats me, any
ideas? All help gratefully accepted.................

Many Thanks

Graham
Udo - 27 Nov 2007 12:05 GMT
On 27 Nov., 12:50, GrahamBaines
<GrahamBai...@discussions.microsoft.com> wrote:
> Hi,
>
[quoted text clipped - 36 lines]
>
> Graham

Hi Graham,

try to substitute the RefreshAll by Calculate.

Good luck
Udo
GrahamBaines - 27 Nov 2007 13:03 GMT
Thanks Udo, tried various configs of the calculate command, it stops the
error but unfortunately doesn't refresh the external data.

Graham

> On 27 Nov., 12:50, GrahamBaines
> <GrahamBai...@discussions.microsoft.com> wrote:
[quoted text clipped - 45 lines]
> Good luck
> Udo
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.