Opening the Specific Excel Sheet Via vb.Net

Hi all,

i need to open specific excel sheet via vb.net using invoke code. I did like that but i did not work.
=> xlsSheet = CType(xlsWB.Sheets(“SheetName”), Microsoft.Office.Interop.Excel.Worksheet)

xlsSheet => Excel.Worksheet
xlsWB => Excel.Workbook

NOT : I have more than one excel sheet.
NOT 2 : I can open excel.
NOT 3 : I cannot use activity

Thank you.

And you can open a single sheet with the code you provided? @yigit.aybey

1 Like

Hi @yigit.aybey ,

Let us know what was the error being faced.

Also, Try replacing the xlsWB.Sheets with xlsWB.WorkSheets and check if it works.

1 Like

hi,

  • I’m not getting an error just not working
  • i replaced but it did not work either.

thx.

hi,

pretty much. I’m dealing with some work in invoke code. i’m not just using an opening a sheet invoke code :slight_smile:

thx

@yigit.aybey ,

If there is no Try-Catch implemented in the Invoke Code and the code did not produce any error, it would be it worked but in Background.

Do you want to open the Excel sheet in foreground ?

Could you let us know what is the task to be done ?

1 Like

Okay @yigit.aybey

Try with this code

xlsSheet = CType(xlsWB.Worksheets(sheetname), Microsoft.Office.Interop.Excel.Worksheet)
xlsSheet.Activate

Pass your sheet name in the parameter

Hope this helps

Regards
Sudharsan

1 Like

It worked buddy thank you. but normally there is no activate code or such thing. I wrote by hand. I do not now why.
Thanks.

1 Like

I implemented the try-catch. The code is working in the background.

I’m opening the excel and it is visible. When it opens sheet_1 opens and i want to open sheet_2 and doing some stuffs there and when finish the work on sheet 2, the program comes back sheet 1 and save and close the excel. Thats all.
But i did it now.
thanks for response and help. :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.