ufrich.blogg.se

Vba insert into word document
Vba insert into word document










vba insert into word document

This will keep the formatted text and lose the richtext "stuff". It takes the value of the field copies it to the clipboard and then pastes it to Word. You will notice that it uses the recordset method from a table to determine the information.

vba insert into word document

I have put the following on a command button on a form. Place the next section in the General area of the Form. Text- brings in the text only no formatting like bolding. Value- brings Everything as you have found out. RE: Insert RTF into WORD PHV (MIS) 20 Apr 04 18:33 Set oWord = CreateObject("Word.Application") HGlobal = GlobalAlloc(GMEM_MOVEABLE Or GMEM_DDESHARE, Len(sRTF))ĬopyMemory lpString, ByVal sRTF, Len(sRTF) LRtf = RegisterClipboardFormat("Rich Text Format") Next add a command button on the form and place the following in the onclick as an event procedure. Private Declare Function lstrcpy Lib "kernel32" (ByVal lstring1 As Any, _ Private Declare Function GlobalFree Lib "kernel32" ( _ Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _īyVal destination As Long, source As Any, ByVal length As Long) Private Declare Function GlobalAlloc Lib "kernel32" (ByVal wflags As Long, _ Private Declare Function GetClipboardData Lib "User32" (ByVal wformat As _ Private Declare Function SetClipboardData Lib "User32" ( _īyVal wformat As Long, ByVal hMem As Long) As Long Private Declare Function CloseClipboard Lib "User32" () As Long Private Declare Function Empt圜lipboard Lib "User32" () As Long "RegisterClipboardFormatA" (ByVal lpString As String) As Long Private Declare Function RegisterClipboardFormat Lib "User32" Alias _ Private Declare Function OpenClipboard Lib "User32" (ByVal hwnd As Long) As Long This will take the richtext copy to the clipboard then open Word and paste the formatted text. First off there are usually more than one way to do most anything.












Vba insert into word document