populate Range in Excel

Fedaykin

Active member
Joined
Mar 20, 2013
Messages
30
Programming Experience
Beginner
I'm a newb to Vb.net, but i've written a few things in VBA. I'm attempting to populate cells in Excel and failing miserably. Here's what I have so far (I grabbed the Dims from other parts of the code to show them here. The part that is not working is opening/filling in the Cell values:



VB.NET:
Public Class Form1

    Dim Excel As Excel.Application
    Dim WorkBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    Dim xlCells As Excel.Range

Private Sub Submit(ByVal LastRev As String, ByVal LastBOM As String)

                Dim BuildType As String
                If Form3.LeadOptionButton.Checked = True Then BuildType = "Leaded"
                If Form3.RoHSOptionButton.Checked = True Then BuildType = "Pb-Free"
                If Form3.UnknownOptionButton.Checked = True Then BuildType = "Unknown"

                Dim BuildType As String
                If Form3.LeadOptionButton.Checked = True Then BuildType = "Leaded"
                If Form3.RoHSOptionButton.Checked = True Then BuildType = "Pb-Free"
                If Form3.UnknownOptionButton.Checked = True Then BuildType = "Unknown"
 
                Excel = New Microsoft.Office.Interop.Excel.Application
                WorkBook = Excel.Workbooks.Open("L:\Projects\" & ProjectIDA & "\Product_Traveler\" & ProjectIDA & "_Traveler.xlsx")
                WorkBook.Activate()
                xlCells("C2").Value = ProjectIDA
                xlCells("J2").Value = Form3.AssyQTYText.Text
                xlCells("A4").Value = BuildType
                xlCells("E2").Value = Form3.PartNumberText.Text
                xlCells("I2").Value = Form3.CustRevText.Text
                xlCells("H4").Value = Form3.FabDateText.Text
                WorkBook.Close(True)
                MsgBox("Project " & ProjectIDA & " Submitted for Assembly", vbOKOnly)

End Sub

End Class
 
Back
Top