>What happens if you use a specific document reference in the Add call?

Interesting you should ask.

This old code I'm using would create the new document and get a file handle 
for it with FCREATE(), then it would leave the file open to "lock" it to 
"avoid surprises". This worked fine in Windows 2000 with VFP 9 SP 1.

Here are my test results with VFP 9 SP 1 in Windows 7:

* In my tests there are no spaces in path or file names, BTW.
cFile = "C:\SomePath\SomeFileThatDoesNotExist.doc"

Test 1:

nHandle = FCREATE(cFile)  && 0 byte file created with specified path\name

WITH oMyWord
      .documents.Add(cFile) && "Word could not open the document" ;
No temp file created
ENDWITH

Test 2:

* No FCREATE(), no file created

WITH oMyWord
      .documents.Add(cFile) && "The document name or path is not valid" ;
No temp file created
ENDWITH

Test 3:

nHandle = FCREATE(cFile)  && 0 byte file created with specified path\name

FCLOSE(nHandle)

WITH oMyWord
      .documents.Add(cFile) && "Could not open macro storage" ;
4 kb temp Word file ("~$" prepended) with specified path\name

ENDWITH


Test 4:

* Original code that worked in Windows 2000 (Yes, the original call was not 
a function call; no parentheses)

nHandle = FCREATE(cFile)  && 0 byte file created with specified path\name

WITH oMyWord
      .documents.Add && "Could not open macro storage" ;
No temp file created
ENDWITH

Test 5:

* No FCREATE(), no file name  && No file created

WITH oMyWord
      .documents.Add && "Could not open macro storage" ;
No temp file created
ENDWITH

Test 6:

nHandle = FCREATE(cFile)  && 0 byte file created with specified path\name

FCLOSE(nHandle)

WITH oMyWord
      .documents.Add && "Could not open macro storage" ;
No temp file created
ENDWITH

In each of these tests, Word created a 1 kb temp file called ~$Normal.dot 
in the properly writeable location I've specified in the Word settings for 
template files:

C:\Users\kend\My Documents\Office Templates\

Then the error occurs and Word hangs and must be killed in the Task Manager.

After each test I killed Word and deleted any orphaned temp files as well 
as any 0 byte word files, and I shut down and restarted VFP.

So, Word at least knows where the template file should be. I assume that 
Word actually opens a temp copy of Normal.dot in memory but then cannot do 
anything with it before the error occurs.

Also, in the test where the file was initially created, then closed, and 
then documents.add(cFile) was called, an actual temporary Word file was 
created before the error occurred. There are additional parameters for 
documents.Add(), including a template file name, a logical variable for 
whether to use a "new template", and an integer variable for, I believe, 
"visible". However, when I try:

documents.add(cFile,cTemplatePathandName,.F.,0)

I get a Word (not VFP) "syntax error".

Any suggestions?

Thanks very much for your help, Richard.

Ken Dibble
www.stic-cil.org


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to