Clipboard paste gives ??

peterhw

New Member
Joined
Jan 23, 2012
Messages
39
I using VBA / Excel (MICROSOFT OFFICE PROFESSIONAL PLUS 2016) / W10 Pro.
I have been using some code (my own) for a while to copy and paste some MT4 code (for Metatrader 4 Forex platform - C++ like code) from a textbox and into my MT4 environment.

The code I require is correct and it pastes correctly in the EXCEL environment but only generates ?? when pasted to MT4. If I copy directly the contents of textbox and paste directly then every " (double quote) is converted to "" (i.e. 2 x double quotes) - a solution but poor. I seem to recollect even this worked ages ago before I copied to the clipboard ready for pasting.

I have added lines for testing but which sort of seem to work but still produces ?? when posted to MT4

Code:
Private Sub MultiPage1_Change()Dim clipboard As MSForms.DataObject
Dim str1  As String, str2 As String, str3 As String, str4 As String
    Sheets("Test").Cells(1, 1) = ""
    Sheets("Test").Cells(1, 2) = ""
    Set clipboard = New MSForms.DataObject
    str1 = TextBox6.Value
    clipboard.SetText TextBox6.Value
    str2 = TextBox6.Value
    clipboard.PutInClipboard
    str3 = "Contents" + vbCrLf + "have been" + vbCrLf + "copied to" + vbCrLf + "Clipboard"
    TextBox9.Value = str3
    Sheets("Test").Cells(1, 1) = str3
    Sheets("Test").Cells(2, 1) = str2
    
    testclipboard (str2)
    
    'Unload Me
End Sub
Sub testclipboard(mytext As String)
Dim str1 As String
Set clipboard = New MSForms.DataObject
    Set MyData = New DataObject
    str1 = mytext
    MyData.SetText mytext
    MyData.PutInClipboard
    'Sheets("Test").Cells(6, 1).Paste
    'TextBox2.Paste
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I can use the following code elsewhere and this would paste the expected code into the MT4 platform

Code:
t1 = "G" + Trim(Str(lg_start - 2)) + ":G" + Trim(Str(lg_end + 3))
    Sheets(ActiveSheet.Name).Range(t1).Copy

This appears to load into the clipboard and can be pasted producing the expecetd results
 
Upvote 0
Just a note , (excel 2010) I have found if you have "File Explorer" open when using the "DataObject" the pasted results are "??"
Maybe your problem is similar !!!
 
Last edited:
Upvote 0
MickG,

Genius - that seems to provide a solution.
I suspect I have used in the past with explorer 'open' - i nearly always have one copy open.

Just a note , (excel 2010) I have found if you have "File Explorer" open when using the "DataObject" the pasted results are "??"
Maybe your problem is similar !!!

Many thanks.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top