• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Excel Macro Stop running

Arunkumar Sekar

New Member
Hi ,

I am using excel sheet to get the reuters market price real time.I used macro to schedule and copy the current worksheet and saveCopy as another work sheet.

But After some times if any one open the other excel sheet,and open the excel option window,my macro stopped running.

Please help me

Code:
Private Seconds As Integer

Sub Workbook_Open()
    Seconds = 5
    ScheduleSaving
End Sub

Sub ScheduleSaving()
    Application.OnTime Now + Seconds / 24 / 3600, "ThisWorkbook.SaveMyWorkbook", Now + 1.5 * Seconds / 24 / 3600
End Sub

Sub SaveMyWorkbook()
    Application.DisplayAlerts = False
        ThisWorkbook.SaveCopyAs "C:\OSTS\Reuters_tmp.xls"
    Application.DisplayAlerts = True
    ScheduleSaving
End Sub
 
Last edited by a moderator:
Hi !

When posting a code, as per forum rules use code tags
or just the code icon ! Thanks …

If anyone open the other workbook, the workbook can't be saved !
And raises the error …
Try with On Error Resume Next statement but data will be lost in this case
or just think about a new strategy for the workbook name
or just detect if workbook is already opened …
 
Thank you Marc noted.

Is there any way to specify the macro only for that sheet ? .If i open other sheets also ,the macro is available to view and execute
 
In your code there is nothing about a sheet !

Save the workbook as .xlsx format (so without code) or
instead of directly saving the workbook,
copy the data worksheet to a new workbook
(see Worksheets.Copy in VBA inner help)
then save this new workbook …
 
Back
Top