Quantcast
Channel: Visual Studio General Questions forum
Viewing all articles
Browse latest Browse all 21115

Opening an excel file from local machine

$
0
0

I created a simple program with one click to open my excel file from local machine, I tried to find the related coding, unfortunately I couldn't get my excel file opens.

Imports Microsoft.Office.Interop
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim xlApp As Microsoft.Office.Interop.Excel.Application
        Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
        Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
        xlApp = New Excel.Application
        xlBook = xlApp.Workbooks.Open("C:\Users\a-datan\Desktop\LyncAutomationConfig.xlsx")
        xlSheet = xlBook.Worksheets("sheet1")

        range = xlSheet.UsedRange

        For rCnt = 1 To range.Rows.Count
        For cCnt = 1 To range.Columns.Count
        Obj = CType(range.Cells(rCnt, cCnt), Excel.Range)
        ' Obj.value now contains the value in the cell.. 
        Next
        Next
    End Sub


Viewing all articles
Browse latest Browse all 21115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>