2012年12月13日 星期四
vbnet xlsx
Imports Microsoft.Office.Interop.Excel
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim cPart As Range
'Dim cLoc As Range
Dim oExcel As Application = CreateObject("Excel.Application")
Dim oBook As Workbook = oExcel.Workbooks.Open("C:\Users\ThisUser\Documents\Data.xlsx", , False)
Dim oSheet As Worksheet
oSheet = oBook.Worksheets("LookupLists")
' To find range in excel and send them to combo box(cboName)
For Each cPart In oSheet.Range("NameRng")
With Me.cboName
.Items.Add(cPart.Value)
'.AddItem(cPart.Value)
'.List(.ListCount - 1, 1) = cPart.Offset(0, 1).Value
End With
Next cPart
oBook.Close()
End Sub
End Class
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言