Doing Unhide in Excel sheet/s

Hi all,

xlsSheet = CType(xlsWB.Sheets(“HideSheet Name”), Microsoft.Office.Interop.Excel.Worksheet)
xlsSheet.Visible = True

NOT : This code gives me an error => convertion error boolean to XlSheetVisibility

How can i do unhide specific sheet or sheets from excel via invoke vb.net ??

Thanks.

HI @yigit.aybey

Try with below code

Sub UnhideAllWoksheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
End Sub

Check out this thread

Regards
Gokul

1 Like

Thx for answer.

But i need to use inside of the invoke code. I cannot use macro

Thx.

Why do need in Invoke code do you have any specific reason?

Check out the thread

Regards
Gokul

2 Likes

Hi @yigit.aybey

Look on the Video

Regards
Gokul

1 Like

Hi

Sheets(“hidesheet”).Visible = True is not working. I’m doing opening the excel etc inside of the invoke code. This code error is => Sheets is and interface type and cannot be used as an expression.

Thx

HI @yigit.aybey

Check with this code


Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlWorkbook As Microsoft.Office.Interop.Excel.Workbook
Dim xlWorksheet As Microsoft.Office.Interop.Excel.Worksheet
xlApp = New Microsoft.Office.Interop.Excel.ApplicationClass
Try
	xlWorkbook = xlApp.Workbooks.Open("Your excel path")
	xlWorksheet = CType(xlWorkbook.Worksheets("Your sheet name"),Microsoft.Office.Interop.Excel.Worksheet)
	xlWorksheet.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetHidden
    xlApp.Visible = False
	xlWorkbook.Save
	xlWorkbook.Close
Catch ex As Exception
	Throw ex
	
Finally
	xlApp.Quit
End Try

Regards
Sudharsan

1 Like

Hi @yigit.aybey ,

Maybe changing the above to the below Expression would work :

xlsSheet.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible

Let us know if it results in an error.

1 Like

Check out this thread @yigit.aybey

Regards
Gokul

1 Like

Thanks for your all helps guys. @Gokul001 @Sudharsan_Ka @supermanPunch

1 Like

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