wayneh
12-03-2008, 08:48 PM
Hi
The following macro to find which table/cell the cursor is currently in works fine in Word 2003 but not in Excel 2003 (I have referenced Word 11 library)
Get runtime error 438 Object does not support this property or method on line beginning "TableIndex = ...."
Any help gratefully received :)
Thanks
Wayne
-------------------------------------------------------------
Sub WhereAreWe()
Dim oDoc As Word.Document
Dim oWord As Word.Application
Set oApp = GetObject(, "Word.Application")
Set oDoc = oApp.ActiveDocument
' Which table are we in ?
TableIndex = oDoc.Range(0, Selection.Tables(1).Range.End).Tables.Count
' Which cell ?
CurrentRow = Selection.Information(wdStartOfRangeRowNumber)
CurrentColumn = Selection.Information(wdStartOfRangeColumnNumber)
MsgBox "Table Number: " & CStr(TableIndex) & vbCrLf _
& "Row Number: " & CStr(CurrentRow) & vbCrLf _
& "Column Number: " & CStr(CurrentColumn)
End Sub
----------------------------------------------------------------
The following macro to find which table/cell the cursor is currently in works fine in Word 2003 but not in Excel 2003 (I have referenced Word 11 library)
Get runtime error 438 Object does not support this property or method on line beginning "TableIndex = ...."
Any help gratefully received :)
Thanks
Wayne
-------------------------------------------------------------
Sub WhereAreWe()
Dim oDoc As Word.Document
Dim oWord As Word.Application
Set oApp = GetObject(, "Word.Application")
Set oDoc = oApp.ActiveDocument
' Which table are we in ?
TableIndex = oDoc.Range(0, Selection.Tables(1).Range.End).Tables.Count
' Which cell ?
CurrentRow = Selection.Information(wdStartOfRangeRowNumber)
CurrentColumn = Selection.Information(wdStartOfRangeColumnNumber)
MsgBox "Table Number: " & CStr(TableIndex) & vbCrLf _
& "Row Number: " & CStr(CurrentRow) & vbCrLf _
& "Column Number: " & CStr(CurrentColumn)
End Sub
----------------------------------------------------------------