Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

wont create document consistently

Status
Not open for further replies.

stibbetts

Technical User
May 6, 2004
64
US
i have this piece of code, it works sometimes, sometimes it gives me an error and if i click debug and then run again it works, sometimes i have to do this a couple times, sometimes it doesnt work at all, on top of that its completely random as to when these happen. ive tried restarting the program, rebooting my computer, doing neither and its still completely random as to when it happens. i think that im going to cry :-(
heres the code:

Public Sub getdwg()
Dim working As DrawingDocument
Set InvApp = GetObject(, "Inventor.Application")
Set working = InvApp.Documents.Add(kDrawingDocumentObject, ("w:\Inventor\Templates\LHW.idw"), True)
Set dwgref = ThisApplication.ActiveDocument
End Sub

anyone know why this might not work so well? by the way, invapp is defined as inventor.applicaion, and dwgref is defines as a dreawingdocument. bot are in the declarations area.
 
Why have you to use the intermediate working object ?
Public Sub getdwg()
Set InvApp = GetObject(, "Inventor.Application")
Set dwgref = InvApp.Documents.Add(kDrawingDocumentObject, ("w:\Inventor\Templates\LHW.idw"), True)
End Sub


Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
oops, forgot to clean that up :-[ but even cleaned up it still doesnt work properly
 
Have you tried to insert a DoEvents call between the two Set instructions ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Set InvApp = GetObject(, "Inventor.Application")
DoEvents
Set dwgref = InvApp.Documents.Add(kDrawingDocumentObject, ("w:\Inventor\Templates\LHW.idw"), True)

like that?
 
Give it a try.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
can anyuone think of anything else that may cause this?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top