Are you running this code from Word or from some other application such as Excel?
You have used an application.ontime version from Word VBA, but also used Set wdApp = GetObject(, "Word.Application") which suggests another application. This is unnecessary when you are already working in Word.
If you are running the code in Excel, you need to change the line to
Code:
Application.OnTime EarliestTime:=Now + TimeValue("00:00:30"), Procedure:="CloseDoc"
and the macro should be
Code:
Sub CloseDoc()
Dim oDoc As Object
Dim wdApp As Object
Set wdApp = GetObject(, "Word.Application")
For Each oDoc In wdApp.Documents
If LCase(oDoc.Name) = "file.docm" Then
oDoc.Close -1
Exit For
End If
Next oDoc
End Sub
where file.docm is the name of the file you want to close.
If you are running the code from Word (not the document with the code) then you only need
Code:
Sub CloseDoc()
Dim oDoc As Word.Document
For Each oDoc In Documents
If LCase(oDoc.Name) = "file.docm" Then
oDoc.Close -1
Exit For
End If
Next oDoc
End Sub