添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • *Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

    Run-time error '-2147417851 (80010105)'

    Forum Search Links
    Morning all,

    I am having difficulty opening a Word document from within a VB6 Project. The error I receive is:

    Run-time error '-2147417851 (80010105)'
    Automation error. The server threw an exception.

    I am relatively new to VB and have searched and tried suggestions with no success. I have included the code below for your review. This activity is for a government project and the need is quite urgent. Any help that you may be able to provide would be most sincerely appreciated.

    Note: wdApp is defined in an initialization module at
    program start.

    A variable is used for the table name as there
    could be several processed by this module.

    Sub ExceltoWord(strXlTbl As String)
    Dim strXLFilePath As String
    strXLFilePath = "C:\PCARSS_v1.0\OutputData\" & strXlTbl
    '*** Open file in WORD and replace tab delimeter with |
    Set wdApp = New Word.Application
    wdApp.Visible = False
    wdApp.Documents.Open FileName:=strXLFilePath, _
    ConfirmConversions:=False, _
    ReadOnly:=False, _
    AddToRecentFiles:=False, _
    PasswordDocument:="", _
    PasswordTemplate:="", _
    Revert:=False, _
    WritePasswordDocument:="", _
    WritePasswordTemplate:="", _
    Format:=wdOpenFormatAuto
    '*** Open text file and select complete document
    wdApp.Selection.WholeStory
    wdApp.Selection.Find.ClearFormatting
    wdApp.Selection.Find.Replacement.ClearFormatting
    '*** Clear any "s
    With wdApp.Selection.Find
    .Text = """"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    wdApp.Selection.Find.Execute Replace:=wdReplaceAll
    '*** Clear any ?'s
    With wdApp.Selection.Find
    .Text = "?"
    .Replacement.Text = ""
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    wdApp.Selection.Find.Execute Replace:=wdReplaceAll
    '*** Replace tab delimeter with | delimiter
    With wdApp.Selection.Find
    .Text = "^t"
    .Replacement.Text = "|"
    .Forward = True
    .Wrap = wdFindAsk
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    wdApp.Selection.Find.Execute Replace:=wdReplaceAll
    '*** Save document as .txt
    wdApp.ActiveDocument.SaveAs FileName:=strXLFilePath, _
    FileFormat:=wdFormatText, _
    LockComments:=False, _
    Password:="", _
    AddToRecentFiles:=True, _
    WritePassword:="", _
    ReadOnlyRecommended:=False, _
    EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, _
    SaveFormsData:=False, _
    SaveAsAOCELetter:=False
    wdApp.ActiveDocument.Close (wdSaveChanges)
    wdApp.Application.Quit
    Set wdApp = Nothing
    End Sub

    RE: Run-time error '-2147417851 (80010105)'



    Which line of your code gives you this error?

    ---- Andy

    RE: Run-time error '-2147417851 (80010105)'

    Thank you Andrzejek for your reply. Sorry for the delay, been in meetings all day.

    The code gives the error at the following line:

    wdApp.Documents.Open FileName:=strXLFilePath, _
    ConfirmConversions:=False, _
    ReadOnly:=False, _
    AddToRecentFiles:=False, _
    PasswordDocument:="", _
    PasswordTemplate:="", _
    Revert:=False, _
    WritePasswordDocument:="", _
    WritePasswordTemplate:="", _
    Format:=wdOpenFormatAuto

    RE: Run-time error '-2147417851 (80010105)'

    I try to recreate your problem, but I couldn't.

    I took your code and try it at my computer.  It works fine.

    You may Google error 2147417851, you will find many hits.  Maybe that will help you.

    ---- Andy

    RE: Run-time error '-2147417851 (80010105)'

    Thanks again for your reply. I will try your suggestion. Hopefully I can find a solution. One positive thing, the code works. Now have to find out why is fails on my computeer. I sincerely appreciate your time in trying to help.

    RE: Run-time error '-2147417851 (80010105)'

    What versions of Word and Excel are on your machine, where it errors out, and what versions are on the machines where it doesn't?

    RE: Run-time error '-2147417851 (80010105)'

    Thanks Andrzejek and SBertHold for pointing me in the right direction. From seraches on the internet I found one that worked and that was to select an earlier version of the Microsoft Active X Data Objects Library. I did this and all appears to be working well. Thanks again I sincerely appreciate you taking time to help me

    RE: Run-time error '-2147417851 (80010105)'

    Google is your best friend in problems like that.

    RE: Run-time error '-2147417851 (80010105)'


    That was what I thought.
    You may have then corrected it just by using late binding.

    Red Flag This Post

    Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

    Red Flag Submitted

    Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
    The Tek-Tips staff will check this out and take appropriate action.

    Reply To This Thread

    Posting in the Tek-Tips forums is a member-only feature.

    Click Here to join Tek-Tips and talk with other members! Already a Member? Login

    Join Tek-Tips ® Today!

    Join your peers on the Internet's largest technical computer professional community.
    It's easy to join and it's free.

    Here's Why Members Love Tek-Tips Forums:

  • Tek-Tips Forums Talk To Other Members
  • Notification Of Responses To Questions
  • Favorite Forums One Click Access
  • Keyword Search Of All Posts, And More...
  • Register now while it's still free!

    Already a member? Close this window and log in.