ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Object doesn't support this property or method (Error 438) (https://www.excelbanter.com/excel-programming/395106-object-doesnt-support-property-method-error-438-a.html)

gazza67[_2_]

Object doesn't support this property or method (Error 438)
 
Hi,

I am using Word 2000 and Excel 2000. I want to run a script in an
excel document that will open a word document, go to a bookmark within
the document and then copy and paste some info from the word document
into the excel document (ie populate the worksheet from a word
document).

I have added a microsoft word reference to my excel script and the
script successfully opens the word document in question. However when
I get to the "Selection.GoTo What:=wdGoToBookmark" statement I get the
error Object doesn't support this property or method (Error 438).

Is anybody able to help me with this problem.

I will include the script code;

Sub CreateNewWordDoc()
' to test this code, paste it into an Excel module
' add a reference to the Word-library
' create a new folder named C:\Foldername or edit the filnames in the
code
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
' Set wrdDoc = wrdApp.Documents.Add ' create a new document
' or
Set wrdDoc = wrdApp.Documents.Open("G:\Gary\testing\handovertes t
\Handovers\Aug\010807.doc")
' open an existing document
' example word operations
With wrdDoc
Selection.GoTo What:=wdGoToBookmark, Name:="aa"
End With
End Sub


Regards,

Gary


JE McGimpsey

Object doesn't support this property or method (Error 438)
 
Running in XL, the Selection object is the range or object selected in
XL, so it knows nothing about how to move in a Word document. Try
something like:

Public Sub GetInfoFromNewWordDoc()
Const sFILENAME As String = _
"G:\Gary\testing\handovertest\Handovers\Aug\010807 .doc"
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim sText As String
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Open(sFILENAME)
With wrdDoc
sText = .Bookmarks("aa").Range.Text
End With
MsgBox sText
End Sub








In article .com,
gazza67 wrote:

Hi,

I am using Word 2000 and Excel 2000. I want to run a script in an
excel document that will open a word document, go to a bookmark within
the document and then copy and paste some info from the word document
into the excel document (ie populate the worksheet from a word
document).

I have added a microsoft word reference to my excel script and the
script successfully opens the word document in question. However when
I get to the "Selection.GoTo What:=wdGoToBookmark" statement I get the
error Object doesn't support this property or method (Error 438).

Is anybody able to help me with this problem.

I will include the script code;

Sub CreateNewWordDoc()
' to test this code, paste it into an Excel module
' add a reference to the Word-library
' create a new folder named C:\Foldername or edit the filnames in the
code
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
' Set wrdDoc = wrdApp.Documents.Add ' create a new document
' or
Set wrdDoc = wrdApp.Documents.Open("G:\Gary\testing\handovertes t
\Handovers\Aug\010807.doc")
' open an existing document
' example word operations
With wrdDoc
Selection.GoTo What:=wdGoToBookmark, Name:="aa"
End With
End Sub


Regards,

Gary


JMB

Object doesn't support this property or method (Error 438)
 
Try:

wrdDoc.Bookmarks("aa").Select

instead of
With wrdDoc
Selection.GoTo What:=wdGoToBookmark, Name:="aa"
End With



"gazza67" wrote:

Hi,

I am using Word 2000 and Excel 2000. I want to run a script in an
excel document that will open a word document, go to a bookmark within
the document and then copy and paste some info from the word document
into the excel document (ie populate the worksheet from a word
document).

I have added a microsoft word reference to my excel script and the
script successfully opens the word document in question. However when
I get to the "Selection.GoTo What:=wdGoToBookmark" statement I get the
error Object doesn't support this property or method (Error 438).

Is anybody able to help me with this problem.

I will include the script code;

Sub CreateNewWordDoc()
' to test this code, paste it into an Excel module
' add a reference to the Word-library
' create a new folder named C:\Foldername or edit the filnames in the
code
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
' Set wrdDoc = wrdApp.Documents.Add ' create a new document
' or
Set wrdDoc = wrdApp.Documents.Open("G:\Gary\testing\handovertes t
\Handovers\Aug\010807.doc")
' open an existing document
' example word operations
With wrdDoc
Selection.GoTo What:=wdGoToBookmark, Name:="aa"
End With
End Sub


Regards,

Gary




All times are GMT +1. The time now is 06:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com