RobMatthews
Board Regular
- Joined
- Nov 16, 2008
- Messages
- 81
I'm copying some data from various places on spreadsheet into a text string on the clipboard, and wanting to manually paste into both a table in Word, and a table in an Outlook email.
The problem is that the spcl character vbTab does not seem to be recognised by either Word or Outlook in the context of a table. The only exception is if more than one cell in the target table is selected.
To test this, Run this code in Excel (or in word, I guess), then open Word and create a table, put the cursor into a cell in the table, and hit Ctrl-V.
Then highlight more than one cell in the table, and Ctrl-V again.
I have also tried Chr(9) and a couple of other options as replacements for vbTab, but I can't figure it out.
Please help.
The problem is that the spcl character vbTab does not seem to be recognised by either Word or Outlook in the context of a table. The only exception is if more than one cell in the target table is selected.
To test this, Run this code in Excel (or in word, I guess), then open Word and create a table, put the cursor into a cell in the table, and hit Ctrl-V.
Then highlight more than one cell in the table, and Ctrl-V again.
Code:
Private Sub TestCopyWithTab()Dim sString As String
Dim DataObj As New MSForms.DataObject
sString = "FirstCell" & vbTab & "2nd Cell"
DataObj.SetText sString
DataObj.PutInClipBoard
End Sub
I have also tried Chr(9) and a couple of other options as replacements for vbTab, but I can't figure it out.
Please help.