Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WORD doc in VFP form??
Message
From
05/03/2008 10:52:25
 
 
To
28/02/2008 10:27:10
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01297370
Message ID:
01298921
Views:
40
>I would like to show a word document IN a vfp form.
>Possible?
>the microsoft word document activex control does not seem to work or if it does I use it wrongly
>
>Peter


Hi Peter

Here is an totally different approach I posted elsewhere using Notepad, but it also works for Word and Excel as well:

Here is a way to do what you want:

1. Create a form
2. Drop a shape on the form and size it to the exact dimensions you want your Word document to be.
3. Set its

VISIBLE = .F.



Now somewhere in your form (maybe in custom method and call it from the INIT) add this code:
DECLARE INTEGER SetParent IN user32;
    INTEGER hWndChild,;
    INTEGER hWndNewParent
DECLARE INTEGER WinExec IN kernel32 STRING  lpCmdLine,;
    INTEGER nCmdShow 
DECLARE INTEGER FindWindow IN user32;
        STRING lpClassName, STRING lpWindowName
DECLARE INTEGER SetWindowPos IN user32;
    INTEGER hwnd,;
    INTEGER hWndInsertAfter,;
    INTEGER x,;
    INTEGER y,;
    INTEGER cx,;
    INTEGER cy,;
    INTEGER wFlags     
* run notepad    
= WinExec("notepad.exe", 1)
* find its hwnd
nHwnd = FindWindow(NULL, "Untitled - Notepad")
* Note you must supply the EXACT Caption of the window)
* force it inside our form
SetParent(nHwnd,ThisForm.HWnd)
* size it
LOCAL nLeft,nTop,nWidth,nHeight
nLeft = ThisForm.shpNotepad.Left
nTop = ThisForm.shpNotepad.Top
nWidth = ThisForm.shpNotepad.Width
nHeight = ThisForm.shpNotepad.Height
SetWindowPos(nHwnd, 1,nLeft, nTop,nWidth, nHeight,64) 
and there you have it. You can also use CREATEOBJECT() to open Word and then you can actually communicate with it using COM while it is restricted to the bounds of your VFP form.
Previous
Reply
Map
View

Click here to load this message in the networking platform