News.Microsoft.com was telling us:
News.Microsoft.com nous racontait que :
> Thanks that got me past the point of the "ActiveX component" error,
> but now it is giving me "Type Mismatch" errors on the placing of data
[quoted text clipped - 26 lines]
> spot and if I comment out that line then it happens a few lines later
> and if I comment out that line, it happens a few lines later etc.
I am not sure if this will solve your problem or not, but you should avoid
the Selection object as much as possible, especially when automating
documents.
Replace each pair of line by a single one like this:
.ActiveDocument.bookmarks("BuildingNumber").Select
.Selection.TypeText USIComboRead(txtBuildingID)
to be replaced by:
.ActiveDocument.bookmarks("BuildingNumber").Range.Text =
USIComboRead(txtBuildingID)
Also, Jean_Yves suggested that you use:
Dim wdlApp As Object ' Declare variable to hold the reference.
Set wdApp = CreateObject("Word.application")
but you are using:
Dim MyWord As Word.Application
Set MyWord = New Word.Application
Any particular reason?
For a more on late binding, see:
http://word.mvps.org/faqs/interdev/earlyvslatebinding.htm
Moreover, do not use ActiveDocument, especially when there might be more
than one document open. You already have a Document object, use it.
Declare it like this:
Dim WordDoc As Object
and use it like this:
Set MyWord = CreateObject("Word.application")
With MyWord
Set WordDoc = .Documents.Open(sWordDocument)
.Visible = True
'.Options.Overtype = True
'Is this necessary? I do not think so
'If it is, do not forget to reset the user setting
'I hate it when some code/application changes
'my settings without telling me
'Something like this
Dim boolUserOverType As Boolean
boolUserOverType = Options.Overtype
.Options.Overtype = True
With WordDoc
.Bookmarks("BuildingNumber").Range.Text =
USIComboRead(txtBuildingID)
.Bookmarks("BuildingName").Range.Text = USIComboRead(cmbBuilding)
'Etc.
End With
'If necessary:
.Options.Overtype = boolUserOverType
End With

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org