Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying text from word to VFP
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00709059
Message ID:
00710544
Views:
17
Alexander,

I will look into this. In the meantime I got a little different advice from someone. It´s a little slower but it works. He suggested to copy the text to a new Word document, to save this file as Rich Text, to read this file into a memory variable (FileToStr) and to write its value into the memo field.
It works but I think your solution will be nicer.

Thanks,
Ron Brahma

>Hi,
>Try this:
>
>Declare Long GlobalLock in Win32API Long hMem
>Declare Long GlobalUnlock in Win32API Long hMem
>Declare Long GlobalSize in Win32API Long hMem
>Declare String lstrcpy in Win32API String @ lpDest, Long lpSrc
>Declare Long OpenClipboard in Win32API Long
>Declare Long CloseClipboard in Win32API
>Declare Long RegisterClipboardFormat in Win32API String
>Declare Long GetClipboardData in Win32API Long uFormat
>
>s = ""
>cf = RegisterClipboardFormat("Rich Text Format")
>If(OpenClipboard(0) != 0)
>    h = GetClipBoardData(cf)
>    If h > 0
>	    len = GlobalSize(h)
>	    s = Replicate(Chr(0), len)
>	    ptr = GlobalLock(h)
>	    lstrcpy(@s, ptr)
>	    s = Left(s, len-1)
>	    GlobalUnlock(h)
>    EndIf
>    CloseClipboard()
>EndIf
>
>? s
>
>>I have a Word document that contains a table. I need to copy data from this table to Word. Creating a Word instance and moving through the table is no problem. The problem starts when copying data from Word to VFP.
>>I use oWord.selection.copy to copy data to the clipboard. This works because I can use the _cliptext variable in VFP to see what the content is.
>>
>>The problem now is that I need to read the ´exact´ content of the clipboard. I need to do this because I need the rich text content of the cell. This means that using _cliptext is out of the question. How can I read the content of the clipboard (as rtf) so I can store the value in a vfp-variable.
Previous
Reply
Map
View

Click here to load this message in the networking platform