How to cancel the Saving to network drive if it took too long time?

Jype61

New Member
Joined
Oct 21, 2016
Messages
1
Hi. New here and not much experience with vba coding.. need help to problem where I couldn't find answer from forums :confused:

I have excel macro that continuously (every 2 minutes) Publish .htm page to network drive. Some times (once a day) the macro stops working when save operation does not end - there is Save dialog box on the screen. When I click "Cancel", macro continue normally.

Publish as method used:
With ActiveWorkbook.PublishObjects.Add(SourceType:=xlSourceRange, _
Filename:="\\Server\Stockreport.htm", Sheet:="First Quarter", Source:="$G$3:$H$6", _
HtmlType:=xlHtmlStatic, DivID:="Book1_4170")
.Publish (True)
.AutoRepublish = False
End With

Question is how vba macro could automatically cancel the saving if it takes more that 5 sec?
I was thinking to use SendKeys method to push "Cancel" button in dialog box, but I do not know how to put that into script so that it would work...
Any better idea instead of SendKeys method?
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,214,593
Messages
6,120,434
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top