Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Ole/Word Automation - In-place activation.
Message
 
 
À
08/05/2001 18:49:16
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00505062
Message ID:
00505138
Vues:
23
Alvaro,

You don't DO the program that contains the DEFINE CLASS command. That code is not really "executed". All you have to do is SET PROCEDURE TO newfile.prg ADDITIVE in order to put the code into the environment so VFP can find the class definition when you do the CreateObject().

>I'm trying make an application with Ole Automation using in-place activation. But i have problems opening an existing file. The only way i see, is defining the class with the documentfile property set, as the shown bellow:
>
>*-----------------
>newfile.prg
>
>DEFINE CLASS oleWordObject as OLEControl
> OleClass ="Word.Document" && Nome do servidor
> DocumentFile = "C:\TEMP\mydoc.DOC"
>ENDDEFINE
>*-----------------
>
>But, if i execute this program, and in my form i add the object like this:
>
>
>cb_newdoc.click
>*-----------------
>do newfile.prg
>
>Thisform.AddObject("olexObject","oleWordObject") <--- Error
>Thisform.olexObject.Visible=.T.
>Thisform.olexObject.DoVerb(-1)
>*-----------------
>In the marked line, i have the message:
>
>'Class definition OLEWORDOBJECT is not found'
>
>So I modifyed the program adding the object in the same program, i define the class:
>
>*-----------------
>newfile.prg
>
>myform.AddObject("olexObject","oleWordObject") <--- Error
>myform.olexObject.Visible=.T.
>myform.olexObject.DoVerb(-1)
>
>DEFINE CLASS oleWordObject as OLEControl
> OleClass ="Word.Document" &&
> DocumentFile = "C:\TEMP\mydoc.DOC"
>ENDDEFINE
>*-----------------
>
>Now, I don't have any error messages, but the VFP shows the 'INSERT OBJECT' window, where i should set the Object Type. Even if i select the Word Document type, the program abort with a fatal error.
>
>I have ever seen the MSDN examples and solutions, but any example works with an existing file. Unless I create all the form manually, as bellow:
>
>NewOleform.prg
>*------------------
>public verbo
>verbo = 0
>*form
>FormWord = CREATEOBJECT('Formnovo')
>FormWord.Closable = .F.
>FormWord.Top = 140
>FormWord.Left = 4
>FormWord.Width = 775
>FormWord.Height = 270
>
>*btn quit
>FormWord.AddObject('cmdCommand1','cmdMyCmdBtn1')
>FormWord.cmdCommand1.caption = '\>FormWord.cmdCommand1.Left = 660
>FormWord.cmdCommand1.Top = 246
>FormWord.cmdCommand1.Height = 25
>
>*btn Print
>FormWord.AddObject('cmdCommand2','cmdMyCmdBtn2')
>FormWord.cmdCommand2.caption = '\>FormWord.cmdCommand2.Left = 550
>FormWord.cmdCommand2.Top = 246
>FormWord.cmdCommand2.Height = 25
>
>*btn edit
>FormWord.AddObject('cmdCommand3','cmdMyCmdBtn3')
>FormWord.cmdCommand3.caption = '\>FormWord.cmdCommand3.Left = 440
>FormWord.cmdCommand3.Top = 246
>FormWord.cmdCommand3.Height = 25
>
>*adiciona objeto de OLE
>FormWord.AddObject("oleObject","oleWordObject")
>
>*torna botões visíveis
>FormWord.cmdCommand1.Visible=.T.
>FormWord.cmdCommand2.Visible=.T.
>FormWord.cmdCommand3.Visible=.T.
>
>*torna ole visível
>FormWord.oleObject.Visible=.T.
>
>*exibe o formulário
>FormWord.Show
>*
>
>*editar ole
>FormWord.oleObject.DoVerb(-1)
>
>*inicia processamento de evento
>READ EVENTS
>
>DEFINE CLASS Formnovo AS FORM
>ENDDEFINE
>
>DEFINE CLASS oleWordObject as OLEControl
> OleClass ="Word.Document" && Nome do servidor
> DocumentFile = "C:\TEMP\TESTE.DOC" && Este arquivo deve existir
> Top = 1
> Left = 4
> Width = 775
> Height = 240
> autosize=.f.
> autoactivate=0
>ENDDEFINE
>
>DEFINE CLASS cmdMyCmdBtn1 AS CommandButton && Cria botão de comando
>
> PROCEDURE Click
> CLEAR EVENTS && Interrompe o processamento do evento, fecha o formulário
>ENDDEFINE
>
>DEFINE CLASS cmdMyCmdBtn3 AS CommandButton && Cria botão de comando
>...
>ENDDEFINE
>
>
>DEFINE CLASS cmdMyCmdBtn2 AS CommandButton && Cria botão de comando
>...
>ENDDEFINE
>
>It works, but will i have to codificate all de form manually?
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform