Run Time Error 438 - Object doesn't support the property or method

P

Paul Cottier

All the calls to Word objects from Excel run except the
run time error 438 on Line:
Selection.TypeText Text:=Labels(i - 1)
This line functions if ececuted within a Word thread.


For i = 1 To MaxLabelCount
LabelModCount = i Mod 80
If LabelModCount = 1 Then
LabelDocCount = LabelDocCount + 1
If LabelDocCount > 1 Then
Application.PrintOut Filename:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1,
Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True,
PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0,
PrintZoomPaperWidth:=0, PrintZoomPaperHeight:=0
Call CloseWordDocument
End If
Call OpenWordDocument(LabelDocCount)
Windows(1).Activate
End If
LabelRowPos = i Mod 4
If LabelRowPos = 1 Then
If Not LabelModCount = 1 Then
Selection.MoveRight Unit:=wdCell
End If
Else
Selection.MoveRight Unit:=wdCell
Selection.MoveRight Unit:=wdCell
End If
Selection.TypeText Text:=Labels(i - 1)
Next
Application.PrintOut Filename:="",
Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=1, Pages:="",
PageType:=wdPrintAllPages, _
Collate:=True, Background:=True,
PrintToFile:=False, PrintZoomColumn:=0, _
PrintZoomRow:=0, PrintZoomPaperWidth:=0,
PrintZoomPaperHeight:=0
Call CloseWordDocument
Exit Sub
ErrorReturn:
Exit Sub
End Sub
Sub CloseWordDocument()
'
' CloseWordDocument Sub
' Sub Created 9/6/2004 by Paul Cottier
'
ActiveDocument.Close
End Sub
Sub OpenWordDocument(DocNum As Integer)
'
' OpenWordDocument Sub
' Sub recorded 9/6/2004 by Paul Cottier
'
Dim docname As String
docname = TargetName & CStr(DocNum)
ChangeFileOpenDirectory _
ApplicationFolder
Documents.Open Filename:=docname,
ConfirmConversions:=False, ReadOnly _
:=False, AddToRecentFiles:=False,
PasswordDocument:="", PasswordTemplate _
:="", Revert:=False, WritePasswordDocument:="",
WritePasswordTemplate:="" _
, Format:=wdOpenFormatAuto

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top