Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Office Automation
Message
De
08/10/2003 13:23:41
 
 
À
08/10/2003 11:05:06
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00836175
Message ID:
00836341
Vues:
18
>>>>>>I am working with office automation. I am trying to pull up a document for word. The data source is linked in the document. It opens fine, does the merge fine, etc. The only thing is when I open it, I get a read only/file in use dialog for the document and then for the data source itself. It is almost like VFP actually uses it before it pulls it up and then will see it as already being in use by yourself. The other problem I am having is after the merge document is created, I would like to keep that avalible with the ability to change, save it, etc., but I want to close the actual form document (showing merge fields, etc.) itself and only show the result (merged document). I have the Microsoft Office Automation for Visual Foxpro book, but I can't seem to find the syntax for closing the form document and leaving the merged document up. Does anyone know what the command is? Can someone help me get rid of the readonly/fileinuse boxes on open?
>>>>>
>>>>>Kevin,
>>>>>Use a template file (.Documents.Add(lcTemplate) vs .Documents.Open(lcDoc)). Cetin
>>>>
>>>>_________________________________________________________
>>>>Cetin,
>>>>
>>>> That helped with my read only / file open thing, thanks a lot. I still have the problem with the template remaining open along with the merged document. How can I close the template document leaving up the merged one for editing, save, etc.?
>>>
>>>You mean the main template itself or the one merged as a new doc ? I think main template :
>>>
>>>
>>>#Define wdSendToNewDocument  0
>>>#DEFINE wdDoNotSaveChanges	0	
>>>
>>>oWordDocument=Createobject("word.application")	&& Create word object
>>>With oWordDocument
>>>*...
>>>  With .ActiveDocument.MailMerge
>>>*....
>>>    .Destination = wdSendToNewDocument
>>>    .Execute
>>>  EndWith
>>>  .Visible = .T.
>>>  .Activate
>>>  .Documents(2).Saved=.t.
>>>  .Documents(2).Close(wdDoNotSaveChanges)
>>>Endwith
>>>
Cetin
>>
>>I got the concept, yes I wanted to close the main document (template) but leave the new merged document open. Thanks a lot. Course I had to alter a little from what you gave me, but I got enough of it to what I needed to. I am trying to understand the logic on this though. Using the with on the created word document we make it visible, I left out the .documents(2).saved=.t. and I was not sure what this did and didn't need it. I understand the define sets up the parameter sent to close and tells it to not save any changes and the close syntax. What is the (2) parameter following the .Documents for?
>
>Saved = .t. simply prevents the dialog and actually was not needed as we're sending the parameter DoNotSave to close.
>Documents in word are like forms in vfp. When you execute the mailmerge there are 2 documents (Template itself and Form letters created). Documents(1) is always the active one and others are on the stack related with their last activation order. Since I know there are only 2 documents and which I want to keep is the active one I simply use its index in collection to find and close. You might keep its reference, loop documents (or windows) to find with its properties etc but here it was safe to directly refer with its index.
>Cetin

That is kind of what I figured it was for. Interesting, how did you pick up on all the syntax for automating office? I got the Automation for Office book and pretty much using it for reference only until I actually get to wanting to build documents and such from stratch, but I can't find code in the samples to do some of the simple things like you just described as saved = .t. makes it think it has already been saved and does not prompt you if you want to. I was curious on if I wanted to make the result of the merged document readonly as to how I would do that because I know evetually they are going to want me to have certain things be read only and I can not even find simple code on how to do that. I could not even find that in Marcia's document. Maybe I am getting blind with my old age, who knows?
``` Appreciate a normal day, it is always better than a bad one ```

Kev
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform