callsloha.blogg.se

Excel vba text clipboard bug
Excel vba text clipboard bug













excel vba text clipboard bug

Set oMail = ActiveExplorer().Selection.Item(1) If its not listed, add C:\Windows\System32\FM20.dll or C:\Windows\FM20.dll as a reference. Remember, if you receive a "User-defined type not defined" you are missing the reference to Microsoft Forms 2.0 Object Library.

excel vba text clipboard bug

What about going in the other direction: copying text to the clipboard? Use PutInClipboard to capture the text. Mail.Subject = mail.Subject & " my text " & strPaste If you receive a "User-defined type not defined" you are missing the reference to Microsoft Forms 2.0 Object Library. Note, you will need to have a reference to the Forms library in Tools, References.

#Excel vba text clipboard bug code#

Note that turning off screen updating is necessary for performance otherwise, go get the paper while you're waiting for the method to complete.The finished code will look something like the following. Underline = IIf(ieControl.SelUnderline, xlUnderlineStyleSingle, xlUnderlineStyleNone) '(strip all chars, they mess up SelStart) 'copy the control's unformatted text to the cell 'clear any existing bold, italic & underline formatting in the cell ' cell A single cell range in a worksheet ' ieControl An Ink Edit control on a form ' Copies the text within an Ink Edit control to a worksheet cell, preserving bold, italic and There must be an easier way to do this that I'm overlooking!ĭoes anyone know how I can copy the formatted text from an Ink Edit control to a worksheet cell, so that all text formatting is preserved?Ĭode: Select all Public Sub CopyInkEditControlToCell(ByVal ieControl As InkEdlib.InkEdit, ByVal cell as Range) The only (perverse) method that seems to work is to: 1) Select all the text in the Ink Edit control 2) Copy the selected text to the clipboard 3) Paste the clipboard into a Word document 4) Copy the text from the Word document to the clipboard 5) Paste the clipboard to the Worksheet cell. I've played around with the DataObject object, to see if I could somehow copy/paste the control's formatted text to the clipboard and then paste it to a worksheet cell. If I assign the control's TextRTF property value, I end up with the control's RTF code, not the actual formatted text from the control. Obviously, if I simply assign the control's Text property value to a worksheet cell, I lose any formatting (no bolding, no italics, etc.). Text returns the control's unformatted text as a string TextRTF returns, also as a string, the "RTF code" representing the formatted text in the control. The Ink Edit control provides two properties, Text and TextRTF, for retrieving the contents of the control. I need to copy the formatted text from my Ink Edit control to a worksheet cell. Or, if no text is selected, you can press Ctrl+B to enable bolding (or unbolding) for any new characters you type.īut here's where I'm stuck (and need your help!). The control behaves as you would expect: you can select all or a portion of the text in the control, then press Ctrl+B to bold (or unbold) the selected text.

excel vba text clipboard bug

In my case, I provided the standard formatting keys Ctrl+B (bold), Ctrl+I (italic) and Ctrl+U (underline) by trapping the control's KeyPress event. You'll need to build in your own 'format editor' for these controls. You'll need to add it to your VBA controls (Tools->Additional Controls, then check the MS Ink Edit Control checkbox). I discovered a MS provided control called an Ink Edit control, which serves nicely as a RichTextBox control. I had the same problem (needing a Rich TextBox type control in Excel 2010).















Excel vba text clipboard bug