I have no idea from your code what ActiveDocument.TT.Caption is supposed to be, but that aside the following will work.
Option Explicit
Sub Update_Fields()
Dim objExcel As Object
Dim exWb As Object
Dim strPath As String
Dim strCaption As String
Dim bStarted As Boolean
If Len(ActiveDocument.Path) = 0 Then GoTo lbl_Exit
On Error Resume Next
Set objExcel = GetObject(, "Excel.Application")
If Err Then
Set objExcel = CreateObject("Excel.Application")
bStarted = True
End If
objExcel.Visible = True 'optional
On Error GoTo 0
strPath = GetWorkbookName(ActiveDocument)
If FileExists(strPath) Then
Set exWb = objExcel.Workbooks.Open(strPath)
strCaption = exWb.Sheets("cost summary").Range("E397").Value
exWb.Close SaveChanges:=False
Else
MsgBox "Workbook not available"
End If
'do something with strCaption here e.g.
ActiveDocument.Variables("varCaption").Value = strCaption
ActiveDocument.Fields.Update
If bStarted Then objExcel.Quit
lbl_Exit:
Set objExcel = Nothing
Set exWb = Nothing
Exit Sub
End Sub
Private Function GetWorkbookName(oDoc As Document) As String
Dim strfName As String
If Len(ActiveDocument.Path) = 0 Then
GoTo err_Handler
End If
strfName = oDoc.FullName
strfName = Left(strfName, InStrRev(strfName, Chr(46)))
GetWorkbookName = strfName & "xls"
lbl_Exit:
Exit Function
err_Handler:
GetWorkbookName = ""
GoTo lbl_Exit
End Function
Private Function FileExists(strFullName As String) As Boolean
Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFullName) Then
FileExists = True
Else
FileExists = False
End If
lbl_Exit:
Exit Function
End Function