Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
runtime error 434, object does not support this method or property | Excel Discussion (Misc queries) | |||
help with my code please. (Error: Object doesn't support this property or method) | Excel Programming | |||
Email error Object dosen't support this property or method | Excel Programming | |||
Object doesn't support this property or method (Error 438) | Excel Discussion (Misc queries) | |||
Run Time Error 438 - Object doesn't support the property or method | Excel Programming |