Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MS Word in a VFP form
Message
From
28/02/2005 13:42:44
 
 
To
28/02/2005 13:21:41
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00991182
Message ID:
00991300
Views:
14
Cetin,

>It'd be much easier and painless if you let word have its own window IMHO.

I may agree with you, but got really excited with the possibilities that such an approach may lead to (many controls in the same form, the possibility to control the way document will be saved - in a memo field for instance, etc).

Please check (and if possible run it) the code below. It is part of a more complex form. So far it is very simple, not sure what it'll be when dealing with showing toolbars and bypassing the open/save dialog.

With proper assistance it would turn into a great implementation!

Regards,

Fernando

PS. Please see UPDATED at the bottom.
 cLoadFileName = "C:\Temp\Test.doc"
 
 oShowWordPage = CreateObj ("frmShowWordPage")

 oShowWordPage.Show ()

 Clear Events

 Define Class frmShowWordPage as Form
*------ ----- --------------- -- ----

        Height      = 600
        Width       = 800
        ControlBox  =  .T.
        MaxButton   =  .T.
        MinButton   =  .T.
        Movable     =  .T.
        ZoomBox     =  .T.
        SizeBox     =  .T.
        Name        = "frmShowWordPage"
        Caption     = " Sample Word Editing Window"
        Closable    =  .T.
        Enabled     =  .T.
        WindowType  =   1 

        Add Object oleBrowserWin  as oleControl  with Top               =   5, ;
                                                      Left              =   5, ;
                                                      Height            = 560, ;
                                                      Width             = 790, ;
                                                      Name              = "oleBrowserWin", ;
                                                      OLEClass          = "Shell.Explorer.2"

        Add Object cmdCancel    as CommandButton with Top               = 570, ;
                                                      Left              = 720, ;
                                                      Height            =  25, ;
                                                      Width             =  75, ;
                                                      FontName          =  "Arial", ;
                                                      FontSize          =   8, ;
                                                      Cancel            = .T., ;
                                                      Caption           = "\<Close"

        Procedure cmdCancel.Click
*                 --------- -----
                  ThisForm.Release
        EndProc

        Procedure oleBrowserWin.Refresh
*                 ------------- -------
                  NoDefault
        EndProc

        Procedure oleBrowserWin.Init
*                 ------------- ----
                  This.Navigate (cLoadFileName)
        EndProc
 
        Procedure QueryUnload
*                 -----------
                  ThisForm.cmdCancel.Click

                  NoDefault

                  Return .T.
        EndProc

 EndDefine
UPDATED

KB article 243058 (How To Use the WebBrowser Control to Open an Office Document) shows how to do it: (http://support.microsoft.com/default.aspx?scid=kb;en-us;243058)

Newer versions of Internet Explorer (5.0 and greater) also allow you to display docked toolbars using the following code:
 ' This is a toggle option, so call it once to show the
 ' toolbars and once to hide them. This works with Internet Explorer 5
 ' but often fails to work properly with earlier versions...
   WebBrowser1.ExecWB OLECMDID_HIDETOOLBARS, OLECMDEXECOPT_DONTPROMPTUSER
and the ExecWB Method (http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/webbrowser/reference/methods/execwb.asp)

accepts many options:
OLECMDID_OPEN                   = 1, 
OLECMDID_NEW                    = 2, 
OLECMDID_SAVE                   = 3, 
OLECMDID_SAVEAS                 = 4, 
OLECMDID_SAVECOPYAS             = 5, 
OLECMDID_PRINT                  = 6, 
OLECMDID_PRINTPREVIEW           = 7, 
OLECMDID_PAGESETUP              = 8, 
OLECMDID_SPELL                  = 9, 
OLECMDID_PROPERTIES             = 10, 
OLECMDID_CUT                    = 11, 
OLECMDID_COPY                   = 12, 
OLECMDID_PASTE                  = 13, 
OLECMDID_PASTESPECIAL           = 14, 
OLECMDID_UNDO                   = 15, 
OLECMDID_REDO                   = 16, 
OLECMDID_SELECTALL              = 17, 
OLECMDID_CLEARSELECTION         = 18, 
OLECMDID_ZOOM                   = 19, 
OLECMDID_GETZOOMRANGE           = 20, 
OLECMDID_UPDATECOMMANDS         = 21, 
OLECMDID_REFRESH                = 22, 
OLECMDID_STOP                   = 23, 
OLECMDID_HIDETOOLBARS           = 24, 
OLECMDID_SETPROGRESSMAX         = 25, 
OLECMDID_SETPROGRESSPOS         = 26, 
OLECMDID_SETPROGRESSTEXT        = 27, 
OLECMDID_SETTITLE               = 28, 
OLECMDID_SETDOWNLOADSTATE       = 29, 
OLECMDID_STOPDOWNLOAD           = 30, 
OLECMDID_ONTOOLBARACTIVATED     = 31, 
OLECMDID_FIND                   = 32, 
OLECMDID_DELETE                 = 33, 
OLECMDID_HTTPEQUIV              = 34, 
OLECMDID_HTTPEQUIV_DONE         = 35, 
OLECMDID_ENABLE_INTERACTION     = 36, 
OLECMDID_ONUNLOAD               = 37, 
OLECMDID_PROPERTYBAG2           = 38, 
OLECMDID_PREREFRESH             = 39, 
OLECMDID_SHOWSCRIPTERROR        = 40, 
OLECMDID_SHOWMESSAGE            = 41, 
OLECMDID_SHOWFIND               = 42, 
OLECMDID_SHOWPAGESETUP          = 43, 
OLECMDID_SHOWPRINT              = 44, 
OLECMDID_CLOSE                  = 45, 
OLECMDID_ALLOWUILESSSAVEAS      = 46, 
OLECMDID_DONTDOWNLOADCSS        = 47, 
OLECMDID_UPDATEPAGESTATUS       = 48, 
OLECMDID_PRINT2                 = 49, 
OLECMDID_PRINTPREVIEW2          = 50, 
OLECMDID_SETPRINTTEMPLATE       = 51, 
OLECMDID_GETPRINTTEMPLATE       = 52 
OLECMDID_PAGEACTIONBLOCKED      = 55,
OLECMDID_PAGEACTIONUIQUERY      = 56,
OLECMDID_FOCUSVIEWCONTROLS      = 57,
OLECMDID_FOCUSVIEWCONTROLSQUERY = 58

OLECMDEXECOPT_DODEFAULT         = 0, 
OLECMDEXECOPT_PROMPTUSER        = 1, 
OLECMDEXECOPT_DONTPROMPTUSER    = 2, 
OLECMDEXECOPT_SHOWHELP          = 3 
However, when I put:
        Procedure oleBrowserWin.Init
*                 ------------- ----
                  This.ExecWB   (OLECMDID_HIDETOOLBARS, OLECMDEXECOPT_DONTPROMPTUSER)
                  This.Navigate (cLoadFileName)
        EndProc
get error message OLE error 0x80040100
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform