简体   繁体   中英

Open Excel File on a specific worksheet through Process.Start() in VB.NET (External Open)

Error I have a database with excel file names stored together with specific worksheet name for each. What I exactly need is to simply open (external) the excel file with the focus to the specific worksheet name.

I simply tried something like following. But it just opens the excel file with the focus on the default worksheet, not the worksheet I want.

Process.Start("X:\\myexcelpath\\myexcelworkbook.xlsx", "myworksheet")

So please let me know how I can do this stuff in vb.net

Thank you.

Unfortunately, you cannot do this through a command line. What I would suggest is that you use the Microsoft.Office.Interop.Excel.

How to manipulate an excel workbook with Excel.Workbook

Dim xlApp As Excel.Application
Dim xlWorkBook As Excel.Workbook
Dim xlWS As Excel.Worksheet

xlApp = New Excel.Application
xlWorkBook = xlApp.Workbooks.Open(sFilePath)
xlWS = CType(xlWorkBook.Worksheets(sheetNameOrIndex), Excel.Worksheet)
xlApp.Visible = True

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM