Last post Jul 08, 2011 10:50 PM by Decker Dong - MSFT
Jul 07, 2011 09:16 AM|ccs1981|LINK
i would like to chack the existence worksheet in the excel file i upload. how to check it, below is my coding in vb.net:
Dim xlsApp As Excel.Application
Dim wbkPA As Excel.Workbook
Dim wshPA As Excel.Worksheet
xlsApp = New Excel.Application
xlsApp.Visible = False
xlsApp.DisplayAlerts = False
wbkPA = xlsApp.Workbooks.Open(viewExcelPath)
if wbkPA.Worksheets.Item("sheet 1").exist = true then 'HOW TO CHECK THE WORKSHEET EXIST OR NOT? wshPA = wbkPA.Worksheets.Item("sheet 1")
appreciate to get your reply soon.
Jul 07, 2011 09:53 AM|Ahmadi_rad|LINK
If you want to write your code in VBA (press Alt+F11), then this is the code:
Sub a() Dim i As Integer Dim s As Worksheet For i = 1 To Sheets.Count Set s = ThisWorkbook.Sheets(i) Debug.Print s.Name NextEnd Sub
I think you can easily change this VBA code to vb.net version. Take care that default start of list index in VBA is 1 bt in .net it startes from 0.
Jul 08, 2011 10:50 PM|Decker Dong - MSFT|LINK
i would like to chack the existence worksheet in the excel file i upload.
In my mind I think you can just send your request here：http://social.msdn.microsoft.com/Forums/en-us/vsto/threads, which supports VS Tools for Office Programming.