![]() IStrPtr = GetClipboardData(CF_UNICODETEXT) If IsClipboardFormatAvailable(CF_UNICODETEXT) Then IStrPtr = GlobalAlloc(GMEM_MOVEABLE Or GMEM_ZEROINIT, iLen) Public Sub SetClipboard(sUniText As String) Private Declare Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyW" (ByVal lpString1 As Long, ByVal lpString2 As Long) As Long Private Declare Function GlobalSize Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As Long) As Long ![]() Private Declare Function GlobalLock Lib "kernel32.dll" (ByVal hMem As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function SetClipboardData Lib "user32.dll" (ByVal wFormat As Long, ByVal hMem As Long) As Long Private Declare Function GetClipboardData Lib "user32.dll" (ByVal wFormat As Long) As Long Private Declare Function IsClipboardFormatAvailable Lib "user32.dll" (ByVal wFormat As Long) As Long Private Declare Function CloseClipboard Lib "user32.dll" () As Long Private Declare Function Empt圜lipboard Lib "user32.dll" () As Long Private Declare Function OpenClipboard Lib "user32.dll" (ByVal hWnd As Long) As Long Private Declare PtrSafe Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyW" (ByVal lpString1 As Any, ByVal lpString2 As Any) As LongPtr Private Declare PtrSafe Function GlobalSize Lib "kernel32" (ByVal hMem As LongPtr) As Long Private Declare PtrSafe Function GlobalUnlock Lib "kernel32.dll" (ByVal hMem As LongPtr) As LongPtr Private Declare PtrSafe Function GlobalLock Lib "kernel32.dll" (ByVal hMem As LongPtr) As LongPtr Private Declare PtrSafe Function GlobalAlloc Lib "kernel32.dll" (ByVal wFlags As Long, ByVal dwBytes As Long) As LongPtr Private Declare PtrSafe Function SetClipboardData Lib "User32" (ByVal wFormat As LongPtr, ByVal hMem As LongPtr) As LongPtr Private Declare PtrSafe Function GetClipboardData Lib "User32" (ByVal wFormat As LongPtr) As LongPtr Private Declare PtrSafe Function IsClipboardFormatAvailable Lib "User32" (ByVal wFormat As LongPtr) As LongPtr Private Declare PtrSafe Function CloseClipboard Lib "User32" () As LongPtr Private Declare PtrSafe Function Empt圜lipboard Lib "User32" () As LongPtr Private Declare PtrSafe Function OpenClipboard Lib "User32" (ByVal hWnd As LongPtr) As LongPtr (Put the below code in a module) Option Explicit This will still need for you to build the functions "SetClipboard" and "GetClipboard".īelow we have the definition of the "SetClipboard" and "GetClipboard" functions, with a few adjustments to fit different excel versions. On Error Resume Next - Needed in case clipboard is empty (Hotkey assignment = Developer tab, Macros, click the macro, options, then put the letter "c" in the hotkey field). You'll need to build a macro as below, and assign the "ctrl+c" as a hotkey to it. Then I'll share the solution which definitely worked well for me, in case others may be in the same situation.įirst, this solution also complies with one bug recently reported to Microsoft, which was causing the clipboard content to be transformed into unreadable content, after any modification using VBA when the user accessed any "Quick Acces Folder" using file explorer.ĭocumentation for the solution of the copy past bug, which the code will be used in this answer, to remove the quotes from clipboard: I was with the same problem and none of the solutions of this post helped me. This is based on Office 2003 so your version of Microsoft Word might be slightly different. ![]() In the, Replace with, field, enter: ^p (2 chars)ĭelete the double-quotes at the beginning and end of the imported.You might have to go to Tools -> AutoCorrect options then both AutoFormat tabs to make sure it doesn't change your straight quotes) In the, Find what, field type in: "^p" (all four characters).Hit Ctrl + H to bring up the Find and Replace dialogue box.You only have to do this if the document contains other stuff that might be affected Use the clipboard symbol dropdown (bottom left of page or pasted text) to select, Keep text only.copy and paste the cells/column into Word.fields as: =A1&" "&B1&CHAR(13)&CHAR(10)&C1&CHAR(13)&CHAR(10)&D1ĬHAR(13) followed by CHAR(10) being a new paragraph when viewing a text file with a hex editor. I came across this problem when I tried to create address labels from First Name, Surname, Address Line 1. It can't be to prep it for a CSV file because they'd be pretty stupid be so sophisticated as to top and tail cells that contain non-printing characters with quotes and not do the same for cells that contain commas (which it doesn't).Īnyway.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |