asmgx
asmgx

Reputation: 8034

Excel Macro Expected Function or variable

I am following this script

https://www.extendoffice.com/documents/excel/3921-excel-save-and-close-workbook-after-inactivity.html

it looks simple and straight forward.

but when I open the excel file I get these errors

---------------------------
Microsoft Visual Basic for Applications
---------------------------
Compile error:

Expected Function or variable
---------------------------
OK   Help   
---------------------------

I am not sure if I am doing anything wrong

but everything looks alright to me

enter image description here

any idea how to fix that?

Thanks K Daves

Do you know why I get error on End Sub and On Error Resume Next?

enter image description here

Upvotes: 2

Views: 587

Answers (1)

K.Dᴀᴠɪs
K.Dᴀᴠɪs

Reputation: 10139

There was an HTML coding error on their website.

In the sub TimeSetting(), it should look like this:

Sub TimeSetting()
    CloseTime = Now + TimeValue("00:00:15")
    On Error Resume Next
    Application.OnTime EarliestTime:=CloseTime, _
      Procedure:="SavedAndClose", Schedule:=True
End Sub

The <span style="background-color:#ff0"> portion that was in your code was actually meant to style the the Sub on their website - not meant to be part of the code.

Upvotes: 2

Related Questions