Hi!
Try to use _VFP.AutoYiels and sys() function related to ActiveX. Some OLE objects also require that form is not visible during adding it to form.
>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?
>
>I would not like to give-up from the in-place activation idea.
>
>I wish someone has already worked as I want to,
>
>TIA,
>
>Alvaro.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.