none
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.Workbooks.Open("ExcelFile.xls")
    MyExcel.Sheets("Sheet1").activate()
    MyExcel.Application.DisplayAlerts = False
    MyExcel.Visible = False
    
    MyExcel.Range("A1").Activate()
    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

Answers

  • 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