Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2003
    Posts
    10

    Unanswered: ActiveX component can't create object....

    Right, here's my next stumbling block!

    My error is:
    ---------------------------------------------
    Run-time error:
    ActiveX component can't create object
    ---------------------------------------------

    Here is my code:
    ---------------------------------------------
    Dim WordApp As Object
    Set WordApp = CreateObject("Word")

    WordApp.Visible = True
    WordApp.Documents.Add "C:/picking_list.doc"

    WordApp.Selection.InsertAfter "Distribution List - Test - " & varDist_Start & " - " & varDist_End & "."

    WordApp.Selection.Font.Bold = True
    WordApp.Selection.Font.Name = "Arial"
    WordApp.Selection.Font.Size = "14"

    WordApp.ActiveDocument.SaveAs "c:/test_dev.doc"

    WordApp.Quit
    ---------------------------------------------

    The error highlights the line that reads:
    ---------------------------------------------
    Set WordApp = CreateObject("Word")
    ---------------------------------------------

    Thanks in advance

    Wes

  2. #2
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    I used a slightly different approach to obtain the results you are looking for.

    Set a reference (VBA Project window -> Tools -> References) to the Microsoft Word Object Lib, then use the following code:

    Function asef()
    Dim WordApp As New Word.Application


    WordApp.Visible = True
    WordApp.Documents.Add "C:/picking_list.doc"

    WordApp.Selection.InsertAfter "Distribution List - Test - - ."

    WordApp.Selection.Font.Bold = True
    WordApp.Selection.Font.Name = "Arial"
    WordApp.Selection.Font.Size = "14"

    WordApp.ActiveDocument.SaveAs "c:/test_dev.doc"

    WordApp.Quit
    Set WordApp = Nothing
    End Function

    ActiveX is probably searching itself for something called Word and coming up short.

    HTH
    All code ADO/ADOX unless otherwise specified.
    Mike.

  3. #3
    Join Date
    Oct 2003
    Posts
    10
    The only problem i have with this is that i do not have a menu for

    VBA Project window -> Tools -> References

    Is there a way of installing something so this will appear?

  4. #4
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    There is not VBA Project Window menu, it is a separate window. You can see this window when you go into your code. You can also press <Alt+F11> to get into this window. Tools is a menu item there, References is a selection under Tools.
    All code ADO/ADOX unless otherwise specified.
    Mike.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •