Snip..
>Hi
>
> You can check the existance of Word by checking one of the
>basic proprety. I have tried following and it works
>
> loword = createobject('word.basic')
> ?TYPE('loword.Filenew') && will return 'c' data type
> *-- Exit word
> ?TYPE('loword.Filenew') && will return 'u' (undefined)
>
> You can also use GETOBJEct Function somewhere in code where
>you allow user to interact with word. i.e.
>
>After executing
>
>oWord = createobject("word.basic")
>with oWord
> .appshow
> cDSN = "DSN=Visual FoxPro Tables;UID=;PWD=;"
> cSourceDb = "SourceDB=C:\Program Files\vfp50\SAMPLES\DATA\Testdata.dbc"
> cSourceType = ";SourceType=DBC;"
> cOther = "Exclusive=No;BackgroundFetch=No;Collate=Machine;"
> cSQLStatement = "SELECT company, contact FROM customer"
> .InsertDatabase(35,511,0, ;
> cDSN+cSourceDb+cSourceType+cOther, ;
> cSQLStatement,,,,,,,1)
>endwith
>
>*-- Add
>IF GETOBJET('word.basic')
> *- do something
>ELSE
> *- Show some message
>ENDIF
Hi Jayesh,
I want to warn you of two things :
1-With type() you get "U" if the word is exited. If not exited the code would continue to execute and "oWord.filenewdefault" would cause to open a new file (surrounding with a "do while" you would just get the system to its knee).
2-Getobject() cannot be used as "if getobject()", it returns an object type. Besides getobject("","word.basic") wouldn't fail and return an object whether a word object exists or not (always .t. if applicable to "if getobject").
Cetin