+ Reply to Thread
Results 1 to 6 of 6

Copy text (form textbox) to clipboard - symbols

  1. #1
    Registered User
    Join Date
    07-09-2014
    Location
    Lisbon
    MS-Off Ver
    Microsoft Office 365 ProPlus Version 1708 (build 8431.2153)
    Posts
    59

    Question Copy text (form textbox) to clipboard - symbols

    Hi everyone,

    So, simple thing: copying text from a textbox to clipboard using VBA. This has been working nicely but I've moved to a Win 10 64-bit & Office 365 ProPlus 32-bit (company laptop) and I'm in hell now!

    Every time I copy something I now get two damn symbols (like this ￿￿, or question marks if pasted to ms word).
    I've searched and as far as I understand there is a workaround using API... but I look at that and it's like quantum physics to me!

    This is the code I'm using (users press a "copy" button):
    Please Login or Register  to view this content.
    I look at a code using API (like this one https://stackoverflow.com/questions/...ndows-10-issue and I can't figure out where or how I tell this thing to get my text from the textbox called "TextForm".

    Can someone please enlighten me?
    Thank you.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    8,803

    Re: Copy text (form textbox) to clipboard - symbols

    I can't test this with your version of Office, but give it a shot.


    Paste this in a standard code module e.g.; Module1

    Please Login or Register  to view this content.

    Use this to copy your textbox text to the clipboard.

    Please Login or Register  to view this content.

    This VBA Method would paste from the clipboard to a textbox.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Guru
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    3,663

    Re: Copy text (form textbox) to clipboard - symbols

    Hi no_Fate,

    Your code uses 'Early Binding'. Before you go to Alpha's API solution, try the equivalent of your code using 'Late Binding':
    Please Login or Register  to view this content.
    For a discussion (and examples of) 'Early Binding' vs. 'Late Binding' see https://peltiertech.com/Excel/EarlyLateBinding.html

    I prefer 'Late Binding' because it does not require a 'Library Reference'. One of the disadvantages of 'Late Binding' is that 'Intellisense' DOES NOT work.

    For more information about 'Intellisense' see:
    https://colinlegg.wordpress.com/2012...isense-part-1/
    https://colinlegg.wordpress.com/2012...isense-part-2/

    Lewis

  4. #4
    Registered User
    Join Date
    07-09-2014
    Location
    Lisbon
    MS-Off Ver
    Microsoft Office 365 ProPlus Version 1708 (build 8431.2153)
    Posts
    59

    Re: Copy text (form textbox) to clipboard - symbols

    Good afternoon,

    Thank you Guys! @LJMetzger, because it was smaller, I've tried you method but unfortunately with the same result. Maybe I was doing something wrong.

    @AlphaFrog, that is working perfectly, thank you!

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,083

    Re: Copy text (form textbox) to clipboard - symbols

    Quote Originally Posted by no_Fate View Post
    Maybe I was doing something wrong.
    FYI, no you weren't. The issue is a bug with the DataObject, so changing the binding context would not help in this case. I believe that the issue only occurs when you have something selected in a Windows Explorer window and you are using Windows 8 or later, though I don't know why.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  6. #6
    Registered User
    Join Date
    07-09-2014
    Location
    Lisbon
    MS-Off Ver
    Microsoft Office 365 ProPlus Version 1708 (build 8431.2153)
    Posts
    59

    Re: Copy text (form textbox) to clipboard - symbols

    Quote Originally Posted by xlnitwit View Post
    FYI, no you weren't. The issue is a bug with the DataObject, so changing the binding context would not help in this case. I believe that the issue only occurs when you have something selected in a Windows Explorer window and you are using Windows 8 or later, though I don't know why.
    Wow... that would explain why "sometimes" it worked (which was driving me nuts, by the way). I've never noticed that pattern. What a weird bug!

    Thank you xlnitwit.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1