0
votes

Hy all. I need some help. I will be very grateful for any help. I don't know about using VBscript in excel.

I am using excel 2016. I have a workbook which has connections to MySQL for query. I want that the data connections in work book may be refreshed at specific time intervals.

I try this code:

Private Sub Workbook_Open()
    Application.OnTime TimeValue("13:55:00"), "MyMacro"
End Sub


Sub MyMacro()
 ActiveWorkbook.RefreshAll
End Sub

The workbook is opened but don't refresh data. Can some one please guide me for adding or editing code for this purpose.

1
Where do you place your codes? - PaichengWu
The first part Workbook_Open i put in ThisWorkbook, and for second MyMacro i created Module1 - stack

1 Answers

0
votes

See http://www.snb-vba.eu/VBA_Application.OnTime_en.html

Try

Private Sub Workbook_Open()
    Application.OnTime TimeValue("13:55:00"), "Module1.MyMacro"
End Sub