Tab Function Question

Huey462

Board Regular
Joined
Jul 25, 2011
Messages
147
I am using VBA to insert a string of text to transfer to another program using the clipboard. The issue I'm running into is that the vbTab function doesn't translate as an actual tab key being pressed. Is there a way to do this without trying to use sendkey?

VBA Code:
Private Sub btnTMP_Click()
‘Declares Variables
Dim obj As New DataObject
Dim txt As String
'Put some text inside a string variable
  txt = "IN" & vbTab & Me!txtMerchNo.Value
'Make object's text equal above string variable
  obj.SetText txt
'Place DataObject's text into the Clipboard
  obj.PutInClipboard
End Sub
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Strange. Your code works just fine for me. I don't know if replacing vbTab with CHR(9) will help, but you could try.
Also, try string(4,chr(32)). Maybe that'll work if your destination app is looking for a count of spaces instead of an actual tab key. Don't know...
 
Upvote 0
I had tried the CHR(9) but it appears that the other application (not a microsoft product) looks at those like a set number of spaces not a tab.
 
Upvote 0
Are you populating two fields in the destination application? If so, then you may be stuck doing two or more operations as you probably have no control over how the other application handles various characters such as CHR(9).
 
Upvote 0
I had tried the CHR(9) but it appears that the other application (not a microsoft product) looks at those like a set number of spaces not a tab.
Do you need the tab in order to move to another field in the other app?
 
Upvote 0
Apologies for the late response. Yes, that is exactly the situation
Hmmm... I can only say that when I've been in this situation, I've had to use SendKeys - very much not ideal. :(
 
Upvote 0

Forum statistics

Threads
1,214,985
Messages
6,122,606
Members
449,089
Latest member
Motoracer88

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