Calling Word 2000 from VB6 'Run-time error '4120': Bad Parameter'

wimblejon
wimblejon used Ask the Experts™
on
Hi,
Can anyone help here?

...simple VB, opening a Word document and sending valid Word macro commands from VB causes an error. Other commandslike 'WordDoc.Selection.TypeParagraph' works fine.
Example follows:

-------------------------------------------------------
Private Sub cmdExtract_Click()
    Dim WordDoc As Object
    Set WordDoc = CreateObject("Word.Application")
    WordDoc.Application.Visible = True
    WordDoc.Application.ChangeFileOpenDirectory _
            "C:\Inetpub\wwwroot\wardour\development\typical_text\"
    WordDoc.Documents.Open FileName:="""CIB News.doc"""
 
   
    WordDoc.Selection.HomeKey Unit:=wdStory, Extend:=wdMove

etc, etc
---------------------------------------------------------


The last line (selection.homekey...) produces a 4120 Bad Parameter error.

Does you know why and please can you help?

Many thanks

Jon
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Have you defined your constants?

wdStory = 6
wdMove = 0

Author

Commented:
er....I hadn't...but have now!!!

Pretty obvious really (...wood for trees etc...)

Many thanks StewartJ

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial