ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Runtime error 429 (https://www.excelbanter.com/excel-programming/369163-runtime-error-429-a.html)

Michelle Hanan

Runtime error 429
 
I have a macro that will not run consistantly, keeps getting runtime errror
429: activex component can't creat object. Are my set and dim codes
wrong:??
Dim myDoc As Word.Document
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal Agency -
Ecology.doc")



Jim Thomlinson

Runtime error 429
 
It needs an instance of Word in which to open the document... Give this a
try...

dim appWord as object
dim myDoc as object

set appWord = CreateObject("Word.Application")
set myDoc =
appWord.Documents.Open("\\powervault2\home_pl\comm on\Referrals\Referal Agency
-
Ecology.doc")
--
HTH...

Jim Thomlinson


"Michelle Hanan" wrote:

I have a macro that will not run consistantly, keeps getting runtime errror
429: activex component can't creat object. Are my set and dim codes
wrong:??
Dim myDoc As Word.Document
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal Agency -
Ecology.doc")




Michelle Hanan

Runtime error 429
 
That seems to work great. I now need to put in a code to close the document
at the end of the macro.I'm just not sure where this needs to be placed.
Here is the ending of the macro. Thanks!
FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
"Jim Thomlinson" wrote in message
...
It needs an instance of Word in which to open the document... Give this a
try...

dim appWord as object
dim myDoc as object

set appWord = CreateObject("Word.Application")
set myDoc =
appWord.Documents.Open("\\powervault2\home_pl\comm on\Referrals\Referal
Agency
-
Ecology.doc")
--
HTH...

Jim Thomlinson


"Michelle Hanan" wrote:

I have a macro that will not run consistantly, keeps getting runtime
errror
429: activex component can't creat object. Are my set and dim codes
wrong:??
Dim myDoc As Word.Document
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal
Agency -
Ecology.doc")






Michelle Hanan

Runtime error 429
 
Maybe this will clear things up a bit. I am running 17 different macros that
call eachother at the end. I need something also at the end to close the
macro so the next one will run. Right now without that code it opens the
first document which is ecology and prints this one 17 times. And all 17
documents are opening with the macro but not printing or closing. This is
what my macros look like:

Sub Ecology()
Dim appWord As Object
Dim myDoc As Object
Set appWord = CreateObject("Word.Application")
Set myDoc =
appWord.Documents.Open("\\powervault2\home_pl\comm on\Referrals\Referal
Agency - Ecology.doc")
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Referrals\Referals.x ls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data
Source=\\powervault2\home_pl\common\Referrals\Refe rals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
, SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
Call Assessor
End With
End Sub

Sub Assessor()
Dim appWord As Object
Dim myDoc As Object
Set appWord = CreateObject("Word.Application")
Set myDoc =
appWord.Documents.Open("\\powervault2\home_pl\comm on\Referrals\Referal
Agency - Assessor.doc")
ActiveDocument.MailMerge.MainDocumentType = wdFormLetters
ActiveDocument.MailMerge.OpenDataSource Name:= _
"\\powervault2\home_pl\common\Referrals\Referals.x ls", _
ConfirmConversions:=False, ReadOnly:=False, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
_
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False,
_
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data
Source=\\powervault2\home_pl\common\Referrals\Refe rals.xls;Mode=Read;Extended
Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet
OLEDB:Registry Path="""";Jet OLEDB:Database Pa" _
, SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="",
SubType:= _
wdMergeSubTypeAccess
With ActiveDocument.MailMerge
.Destination = wdSendToPrinter
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
Call BuildingFireSafety
End With
End Sub
"Michelle Hanan" wrote in message
...
That seems to work great. I now need to put in a code to close the
document at the end of the macro.I'm just not sure where this needs to be
placed.
Here is the ending of the macro. Thanks!
FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
End Sub
"Jim Thomlinson" wrote in
message ...
It needs an instance of Word in which to open the document... Give this a
try...

dim appWord as object
dim myDoc as object

set appWord = CreateObject("Word.Application")
set myDoc =
appWord.Documents.Open("\\powervault2\home_pl\comm on\Referrals\Referal
Agency
-
Ecology.doc")
--
HTH...

Jim Thomlinson


"Michelle Hanan" wrote:

I have a macro that will not run consistantly, keeps getting runtime
errror
429: activex component can't creat object. Are my set and dim codes
wrong:??
Dim myDoc As Word.Document
Set myDoc =
Word.Documents.Open("\\powervault2\home_pl\common\ Referrals\Referal
Agency -
Ecology.doc")









All times are GMT +1. The time now is 10:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com