Error 438

sts023

New member
Joined
Nov 30, 2016
Messages
5
Reaction score
0
Points
0
Age
73
Location
God's Own County
Excel Version(s)
2010 14.0.7212.5000 (32 bit)
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
 
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?
 
Back
Top