VB.Net Microsoft.Office.Interop.Excel Paste from MultiLine TextBox to Excel. RRS feed

  • Question

  • I want to paste contents from a multi line textbox to excel.  the code below will paste all into cell A1 and I need it to paste down the column.  

    Dim MyExcel As New Excel.Application
    MyExcel.Application.DisplayAlerts = False
    MyExcel.Visible = False
    MyExcel.ActiveCell.Formula = tbUserID.Text
    If you do it manually in the Excel GUI RMC and Paste it works.  if you RMC and put = then paste same issue.  any help is greatly appreciated.  

    Work Smarter Not Harder

    Friday, July 6, 2018 2:12 PM


  • the Answer: 

    Dim oItem As Object Dim OffS As Integer

    OffS = 0 For Each oItem In tbUserID.Lines MyExcel.Sheets("Sheet1").Range("A1").Offset(OffS, 0).Value = oItem OffS = OffS + 1 Next oItem

    Work Smarter Not Harder

    Friday, July 6, 2018 8:15 PM