Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word Problems
Message
From
24/09/2003 12:32:20
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Title:
Miscellaneous
Thread ID:
00831825
Message ID:
00831886
Views:
13
What happens if you check to ensure that oWord is null (and wait for it to be so) before you open a document everytime?

What happens if you try something like:
lncount = 0
DO WHILE lncount < 4
    IF checkit()
        WAIT WINDOW "Close Word to continue" NOWAIT
	oWord = createobject('Word.Application')
	with oWord
	 .visible=.t.
	 .Activate
	ENDWITH
    ENDIF
lncount = lncount+1
ENDDO
RETURN





FUNCTION checkit
*-------- ------------

DECLARE Sleep IN Win32API;
	INTEGER nMilliseconds

DO WHILE .T.
	If IsAppRunning( "OpusApp")            &&  Checks if MS-Word already running
		= Sleep(10) && Wait a 1/100th of a second.
	ELSE
		WAIT WINDOW "Word was just closed." TIMEOUT 10
		EXIT
	ENDIF
ENDDO
RELEASE oWord
CLEAR DLLS "sleep"
RETURN .T.

FUNCTION CheckWin
*-------- ------------
	PARAMETER tcTitle

	* Routine which sees if an application is active by looking for its
	* Window title
	* expC1 Window title

	DECLARE INTEGER FindWindow in Win32API as FindWindow STRING, STRING

	RETURN IIF(FindWindow(0,tcTitle)>0,.T.,.F.)


 Function IsAppRunning     
*-------- ------------
 LParameters pAppClassName

 Private cClassName, cNullPointer, nRetCode

 nRetCode      = 0
 cNullPointer  = .Null.
 cAppClassName = pAppClassName

 Declare Integer FindWindow In Win32API As CheckForWindow ;
         String  @cAppClassName, ;
         String  @nNullPointer

 nRetCode = CheckForWindow (@cAppClassName, @cNullPointer)

 Release cClassName, cNullPointer

 Return IIf (nRetCode = 0, .F., .T.)

 EndFunc     
>I am opening and closing word very quickly and sometimes I get an error:
>80010105: The server threw an exception
>
>The line this error occurs on is:
>oWordApp.Documents.Open('MyDoc')
>
>This doesn't occur all the time and it doesn't even occur at all on some computers. However the computer it is currently happening to is very fast and has WinXP and OfficeXP. Can anyone give me a little guidence on this. I can't seem to find much on Microsoft's site.
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Previous
Reply
Map
View

Click here to load this message in the networking platform