Launching Word hangup

Launching Word hangup

Anonymous
Not applicable
115 Views
3 Replies
Message 1 of 4

Launching Word hangup

Anonymous
Not applicable
Hi all.

A macro I use to launch Word2000 from LDD2 (Acad2000) sometimes needs to be
loaded twice to run for some strange reason. Only in N.T. however.

Here is the code, a user is getting the "cannot load Word" message the first
time. If the macro is loaded a second time it runs. Any ideas? Thanks.

Sub QLEGALP()
Dim WDAPP As Object
On Error Resume Next
Set WDAPP = GetObject(, "WORD.APPLICATION")
If Err <> 0 Then
Err.Clear
Set WDAPP = CreateObject("WORD.APPLICATION")
If Err <> 0 Then
MsgBox "Could not load Word"
End
End If
End If
WDAPP.Visible = True
WDAPP.Application.WindowState = wdWindowStateMaximize
WDAPP.Documents.Add Template:="C:\q-LEGAL\Qlegal-d.dot", NewTemplate:=False
End Sub
0 Likes
116 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Bud,

I don't use the CreateObject method but rather the following

Public mobjWord As Word.Application

Set StartWord2000 = New Word.Application

Works everytime that I know about. I used this in a recent article for
Sources.
--
Joe Sutphin
Author of "AutoCAD 2000 VBA Programmers Reference"
ISBN #1861002564 Order it at
http://www.amazon.com/exec/obidos/ASIN/1861002564/o/qid%3D942504788/sr%3D8-1
/002-7788324-2908264

Checkout Sources - the only magazine dedicated to AutoCAD customization
http://vbdesign.hypermart.net/sources/

Bud Miller wrote in message
news:B885FF29EBB5AF4261AD40DC4465E970@in.WebX.SaUCah8kaAW...
> Hi all.
>
> A macro I use to launch Word2000 from LDD2 (Acad2000) sometimes needs to
be
> loaded twice to run for some strange reason. Only in N.T. however.
>
> Here is the code, a user is getting the "cannot load Word" message the
first
> time. If the macro is loaded a second time it runs. Any ideas? Thanks.
>
> Sub QLEGALP()
> Dim WDAPP As Object
> On Error Resume Next
> Set WDAPP = GetObject(, "WORD.APPLICATION")
> If Err <> 0 Then
> Err.Clear
> Set WDAPP = CreateObject("WORD.APPLICATION")
> If Err <> 0 Then
> MsgBox "Could not load Word"
> End
> End If
> End If
> WDAPP.Visible = True
> WDAPP.Application.WindowState = wdWindowStateMaximize
> WDAPP.Documents.Add Template:="C:\q-LEGAL\Qlegal-d.dot",
NewTemplate:=False
> End Sub
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
Hi Joe,

I need this to also work for Word97. Also, I'm a little unclear about how to
call what you gave me. I'm getting a "User defined type not defined" error.

Any additional info would be appreciated.

Bud Miller

"Joe Sutphin" wrote in message
news:1ACDF37D97110E8DE1B967B558B635B7@in.WebX.SaUCah8kaAW...
> Bud,
>
> I don't use the CreateObject method but rather the following
>
> Public mobjWord As Word.Application
>
> Set StartWord2000 = New Word.Application
>
> Works everytime that I know about. I used this in a recent article for
> Sources.
> --
> Joe Sutphin
> Author of "AutoCAD 2000 VBA Programmers Reference"
> ISBN #1861002564 Order it at
>
http://www.amazon.com/exec/obidos/ASIN/1861002564/o/qid%3D942504788/sr%3D8-1
> /002-7788324-2908264
>
> Checkout Sources - the only magazine dedicated to AutoCAD customization
> http://vbdesign.hypermart.net/sources/
>
> Bud Miller wrote in message
> news:B885FF29EBB5AF4261AD40DC4465E970@in.WebX.SaUCah8kaAW...
> > Hi all.
> >
> > A macro I use to launch Word2000 from LDD2 (Acad2000) sometimes needs to
> be
> > loaded twice to run for some strange reason. Only in N.T. however.
> >
> > Here is the code, a user is getting the "cannot load Word" message the
> first
> > time. If the macro is loaded a second time it runs. Any ideas? Thanks.
> >
> > Sub QLEGALP()
> > Dim WDAPP As Object
> > On Error Resume Next
> > Set WDAPP = GetObject(, "WORD.APPLICATION")
> > If Err <> 0 Then
> > Err.Clear
> > Set WDAPP = CreateObject("WORD.APPLICATION")
> > If Err <> 0 Then
> > MsgBox "Could not load Word"
> > End
> > End If
> > End If
> > WDAPP.Visible = True
> > WDAPP.Application.WindowState = wdWindowStateMaximize
> > WDAPP.Documents.Add Template:="C:\q-LEGAL\Qlegal-d.dot",
> NewTemplate:=False
> > End Sub
> >
>
0 Likes
Message 4 of 4

Anonymous
Not applicable
Goto Tool > References... then select Microsoft Word 9.0 object library

amy

"Bud Miller" wrote in message
news:CC85E3D127CB1FA4A93060E3D0239AD5@in.WebX.SaUCah8kaAW...
> Hi Joe,
>
> I need this to also work for Word97. Also, I'm a little unclear about how
to
> call what you gave me. I'm getting a "User defined type not defined"
error.
>
> Any additional info would be appreciated.
>
> Bud Miller
>
> "Joe Sutphin" wrote in message
> news:1ACDF37D97110E8DE1B967B558B635B7@in.WebX.SaUCah8kaAW...
> > Bud,
> >
> > I don't use the CreateObject method but rather the following
> >
> > Public mobjWord As Word.Application
> >
> > Set StartWord2000 = New Word.Application
> >
> > Works everytime that I know about. I used this in a recent article for
> > Sources.
> > --
> > Joe Sutphin
> > Author of "AutoCAD 2000 VBA Programmers Reference"
> > ISBN #1861002564 Order it at
> >
>
http://www.amazon.com/exec/obidos/ASIN/1861002564/o/qid%3D942504788/sr%3D8-1
> > /002-7788324-2908264
> >
> > Checkout Sources - the only magazine dedicated to AutoCAD customization
> > http://vbdesign.hypermart.net/sources/
> >
> > Bud Miller wrote in message
> > news:B885FF29EBB5AF4261AD40DC4465E970@in.WebX.SaUCah8kaAW...
> > > Hi all.
> > >
> > > A macro I use to launch Word2000 from LDD2 (Acad2000) sometimes needs
to
> > be
> > > loaded twice to run for some strange reason. Only in N.T. however.
> > >
> > > Here is the code, a user is getting the "cannot load Word" message the
> > first
> > > time. If the macro is loaded a second time it runs. Any ideas? Thanks.
> > >
> > > Sub QLEGALP()
> > > Dim WDAPP As Object
> > > On Error Resume Next
> > > Set WDAPP = GetObject(, "WORD.APPLICATION")
> > > If Err <> 0 Then
> > > Err.Clear
> > > Set WDAPP = CreateObject("WORD.APPLICATION")
> > > If Err <> 0 Then
> > > MsgBox "Could not load Word"
> > > End
> > > End If
> > > End If
> > > WDAPP.Visible = True
> > > WDAPP.Application.WindowState = wdWindowStateMaximize
> > > WDAPP.Documents.Add Template:="C:\q-LEGAL\Qlegal-d.dot",
> > NewTemplate:=False
> > > End Sub
> > >
> >
>
0 Likes