I'm trying to write a method to transpose tables in Word using Visual Basic and the Excel object model. However, I'm having trouble using paste special with the copied Word object, since its not just plain text.
Is it possible to force a plain text paste with transpose? Is there a better way to do this?
My current code is as follows:
Public Sub transposeTable()
Selection.Copy
Dim oXlApp As New Excel.Application
Dim oXlBook As Excel.Workbook
Set oXlApp = CreateObject(Class:="Excel.Application")
Set oXlBook = oXlApp.Workbooks.Add
oXlBook.Sheets(1).Range("A1").Select
oXlApp.ActiveCell.PasteSpecial Transpose:=True
oXlBook.Sheets(1).Cells.SpecialCells(xlCellTypeConstants).Select
oXlApp.Selection.Copy
Selection.Paste
End Sub
The error I'm recieving is:
Run-time error '1004':
PasteSpecial method of Range class failed