Automation error-re-try

V

Van S. Mabrito

Hello
I posted the following problem previously but didn't get a response and I need to find a solution. Perhaps it is too challenging to deal with, but I wanted to try again, and see if someone could tackle it, or at least tell me where I might find a solution
Thanks, regard
Va

Hello
I have an Excel/Word VBA app with automation. Excel VBA
has a routine to open a Word doc via automation, and uses
the Find/Replace methods to populate the pre-formatted
Word template. It has worked fine under Office 97, 2000
and XP but now (not sure this is the reason) under Office
2003, I get an error (code follows) at the statement
...replacement.Text = StrConv(Worksheets("Dealer
Info").Range("rngDirDealerNm").Value, vbProperCas

The err.number = -2147023151 and the err.description
"Automation error The procedure number is out or range.
I checked the knowledge base and found no references to
this error
Any ideas what the problem could be
Thanks and God bless
Va

Set wrd = CreateObject("Word.Application"
For ndxMain = 1 To strQtNd

If ndxMain = 1 Then ' 1st pag
wrd.Documents.Add Template:=
mstrTmpltPath & "Quote.dot" ' chg to allow any
path*****
'Debug.Print wrd.Documents(1).Nam
'wrd.Documents("Document3").Clos

strFileNm = strCourse & " " & strDate & ".doc
booFName = Fals
docFileName = "
D

docFileName = Application.GetSaveAsFilenam
(InitialFileName:=mstrPath & "\Saved Quotes\" &
strFileNm,
fileFilter:="Word document (*.doc),*.doc",
Title:="Save Copy of Printed Quote As:"
If docFileName <> "" The
booFName = Tru
End I
Loop Until booFName <> Fals

' Debug.Print wrd.ActiveDocument.Nam
wrd.ActiveDocument.SaveAs Filename:=docFileNam

Else ' page 2 &
wrd.Documents.Add Template:=
mstrTmpltPath & "Quote2.dot" ' chg to allow any
path*****

End I
Dim nm As Documen
Dim x As Intege

wrd.WindowState = wdwindowstatenorma

With wrd.Selection.Fin
' Dealer header field
' find and replace dealer Hdr nam
.Text = "dealerhdrFld
.replacement.Text = StrConv(Worksheets("Dealer
Info").Range("rngDirDealerNm").Value, vbProperCase
.Execute Replace:=wdReplaceAll, Forward:=Tru
 
P

Peter Hewett

Hi Van S. Mabrito

Well the first thing you need to do is work out which application is causing the
problem! So you need to do two things. Split the following statement into two
parts:

.replacement.Text = StrConv(Worksheets("Dealer Info") _
.Range("rngDirDealerNm").Value, vbProperCase) _
.Execute Replace:=wdReplaceAll, Forward:=True

becomes:

Dim strValue as String
strValue = StrConv(Worksheets("Dealer Info") _
.Range("rngDirDealerNm").Value, vbProperCase) _
.Execute Replace:=wdReplaceAll, Forward:=True
Msgbox strValue
.replacement.Text = strValue

This is pretty basic divide and conquer problem determination and should always
be the first thing you do.

Post again if you can't work out what the problem is once you have more
information.

HTH + Cheers - Peter
 

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

Similar Threads

Automation error 0

Top