error using GetObject - "cannot create ActiveX component"

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ironmanlarry
    New Member
    • Aug 2007
    • 9

    error using GetObject - "cannot create ActiveX component"

    Hi,

    I'm trying to do a mail merge from Excel to Word (programaticall y) and I'm having some trouble creating the Word Document Object. This line of code
    wordDoc = GetObject("shee t.doc")
    keeps returning the error "cannot create ActiveX component" and then the program crashes.
    Any help is much appreciated. Thank you.

    Larry
  • fplesco
    New Member
    • Jul 2007
    • 82

    #2
    Originally posted by ironmanlarry
    Hi,

    I'm trying to do a mail merge from Excel to Word (programaticall y) and I'm having some trouble creating the Word Document Object. This line of code
    wordDoc = GetObject("shee t.doc")
    keeps returning the error "cannot create ActiveX component" and then the program crashes.
    Any help is much appreciated. Thank you.

    Larry
    Hi -

    I think you're doing shortcut here. You have to had word application open first.
    wordDoc = GetObject("Word .Application")

    if above code raises an error, you have to code
    wordDoc = CreateObject("W ord.Application ")

    and from here, try to open "sheet.doc"

    Comment

    • ironmanlarry
      New Member
      • Aug 2007
      • 9

      #3
      Thank you for the help.

      I was actually able to get it to work using the GetObject call. I think it needed the full path of the file to open.
      However, when I try to run the program from a C++ program, it doesn't work. Do you know anything about that?

      Thanks, Larry

      Originally posted by fplesco
      Hi -

      I think you're doing shortcut here. You have to had word application open first.
      wordDoc = GetObject("Word .Application")

      if above code raises an error, you have to code
      wordDoc = CreateObject("W ord.Application ")

      and from here, try to open "sheet.doc"

      Comment

      Working...