General information
Category:
COM/DCOM and OLE Automation
>I created the following program and called it from a CommandButton Click event on a form. I have the OLE object (word) display on the form Isometric, the user needs to double click to activate word.
>
>
>PARAMETERS pcFile, frmType
>
>RELEASE oForm
>PUBLIC oForm
>
>oForm = CREATEOBJECT("Form") && Create Form
>oForm.Closable = .F. && Disable Close button
>oForm.Width = 414 && Form height
>oForm.Height = 453 && Form width
>oForm.AutoCenter = .T.
>IF frmType = "LETTER"
> oForm.Caption = "View/Modify Letter"
>ELSE
> oForm.Caption = "View/Modify Template"
>ENDIF
>oForm.WindowType = 1
>
>oForm.AddObject("shape1", "shpMyShape") && Add Shape
>oForm.AddObject("cmdExit", "cmdMyCmdBtn" && Add Exit Command Button
>oForm.AddObject("oleObject", "oleWord") && Add Ole Container object
>
>oForm.cmdExit.Visible = .T. && Display Exit button
>oForm.Shape1.Visible = .T.
>
>oForm.oleObject.Left = 24
>oForm.oleObject.Height = 409
>oForm.oleObject.Width = 313
>oForm.oleObject.Top = 12
>oForm.oleObject.Visible = .T.
>oForm.oleObject.Stretch = 1 && isometric
>
>oForm.Show && Display the form
>
>CLEAR CLASS oleWord
>CLEAR CLASS cmdMyCmdBtn
>CLEAR CLASS shpMyShape
>
>DEFINE CLASS oleWord AS OleControl
> OleClass = "Word.Document.8"
> DocumentFile = pcFile
> OleTypeAllowed = 0
>ENDDEFINE
>
>DEFINE CLASS cmdMyCmdBtn As CommandButton && Create Command Button
> Caption = "E\> Cancel = .T. && Default Exit command button
> Width = 61
> Height = 25
> Left = 348
> Top = 408
>
> PROCEDURE Click
> oForm.RemoveObject("oleObject")
> oForm.RemoveObject("cmdExit")
> oForm.RemoveObject("shape1")
> oForm.Release
>ENDDEFINE
>
>
>DEFINE CLASS shpMyShape As Shape && Create Shape
> BackColor = 16777215 && shape fill color
> BackStyle = 1
> Left = 12
> Top = 0
> Height = 433
> Width = 328
>ENDDEFINE
Looks good. This is one place where I would pass the parameter as PRIVATE instead of local. The problem we have is that when calling Lotus Word Pro as we're doing, the form that calls launches LWP, is already up and I still have to change the name of the file on the fly.
But by calling a form and adding the object on the fly, I was able to get the DocumentFile changed. It still feels like a kludge though.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only