Results 1 to 2 of 2

Thread: Error 438

  1. #1
    Seeker sts023's Avatar
    Join Date
    Nov 2016
    Location
    God's Own County
    Posts
    5
    Articles
    0
    Excel Version
    2010 14.0.7212.5000 (32 bit)

    Error 438



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hi all, and Merry Christmas!
    I had a Word 2010 document which used to be able to read Worksheets from an Excel 2010 document.
    My PC wandered off to the great scrapyard in the sky, and on buying a new one I had some other priorities (and in any case this was a personal project, so not urgent).
    On resurrecting the unfinished project on my new PC, I kept on getting “ Error 438: Object doesn’t support this property or method”.
    After some research it looked like a common problem was that either Word, Excel, or the Word document may have become corrupt, so I removed “Microsoft Office Professional Plus 2010” and reinstalled it.
    I then wrote the following code based on the excellent offerings from Greg Maxey and installed it in a new Word 2010 document.
    I still have the same problem.
    Can any kind soul offer any help or advice on how to get Word 2010 to read an Excel spreadsheet without the Error 438?
    The failing sample code is below.
    Thanks in advance…
    Code:
    Public Sub Maxey()
    Dim objXLApp                        As Object
      On Error Resume Next
    '*
    '** If we already have an instance of
    '** Excel open, use it.
    '*
      Set objXLApp = GetObject(, "Excel.Application") 'Uses an existing instance.
      If Err.Numnber <> 0 Then
        Call MsgBox("Existing instance fails" & vbCrLf & _
                    "Error number: " & Err.Number & vbCrLf & _
                    Err.Description, _
                    vbInformation, _
                    "Existing")
    '*
    '** No exxisting instance of Excel, so
    '** create one.
    '*
      Set objXLApp = CreateObject("Excel.Application") 'Creates instance.
        If Err.Numnber <> 0 Then
        Call MsgBox("New instance fails" & vbCrLf & _
                    "Error number: " & Err.Number & vbCrLf & _
                    Err.Description, _
                    vbInformation, _
                    "New")
        End If
     End If
     On Error GoTo 0
    End Sub 'Maxey

  2. #2
    Seeker sts023's Avatar
    Join Date
    Nov 2016
    Location
    God's Own County
    Posts
    5
    Articles
    0
    Excel Version
    2010 14.0.7212.5000 (32 bit)

    Supplementary info...

    Now getting the dreaded Error 48 on the "Documents.Add" line(s) with the following code:-

    In a "Global definitions" module
    Code:
    Option Explicit
     
    Public gobjWordApp              As Object
    Public gobjWordDoc              As Object
     
    Public gstrErrMsg               As String
     
    Public gwdApp                   As Word.Application
    Public gwdDoc                   As Word.Document
    In the executing module, variations around the following code (see some commented out code line) I'm getting Error 48
    Code:
    Option Explicit
    Public Sub StartWordDoc()
    Dim intE1                       As Integer
    Dim objWdApp                    As Object
    Dim strE1                       As String
    '*
    '** Create a new Word document using
    '** "late binding" (for some reason "early
    '** binding doesn't seem to work).
    '** Word may or may not currently be active,
    '** so we either use GetObject (existing)
    '** or CreateObject (new).
    '*
      On Error Resume Next
      Set objWdApp = GetObject(, "Word.Application")
      If Err.Number <> 0 Then
    '*
    '** No existing Word application.
    '** Record the error in case all methods fail.
    '*
        intE1 = Err.Number
        strE1 = Err.Description
    '*
    '** Try to instance a new Word application.
    '*
        Err.Clear
        Set objWdApp = CreateObject("Word.Application")
        If Err.Number <> 0 Then
    '*
    '** Can't use existing or create new!
    '*
          gstrErrMsg = "Cannot create a Word document" & vbCrLf & _
                       """Get"" resulted in the following error" & vbCrLf & _
                       intE1 & vbCrLf & _
                       strE1 & vbCrLf & _
                       """Create"" resulted in the following error" & vbCrLf & _
                       Err.Number & vbCrLf & _
                       Err.Description
          Call AbortMeNow
        End If 'CreateObject
      End If 'GetObject
      On Error GoTo 0
    '*
    '** We have an instance of Word.
    '** As "early binding has advantages.
    '** use "Set" to achieve those advantages.
    '*
    '  Set gwdApp = objWdApp
    '  Set objWdApp = Nothing
    '*
    '** Create a new Word document.
    '*
    '  gwdApp.Documents.Add
      objWdApp.Visible = True
      Set gwdDoc = objWdApp.Documents.Add
    End Sub 'StartWordDoc
    I get similar results when I "invert" and try to use Word 2010 to read an Excel spreadsheet.
    I've tried various "DLL cleaners" to no avail.
    It may help if anyone knew a way to get Excel/Word to identify which DLL is failing - any ideas?

Tags for this Thread

Posting Permissions

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