Unable to hide Excel sheet while Excel application is hidden.

Tsutsumi 26 Reputation points
2022-01-21T00:48:12.803+00:00

Hello all,

I created the following code using "VB.net", but when I try to execute the following code, an error 0x800A30EC occurs
when I specify "xlSheetHidden.Visible" as hidden and I cannot execute it.

However, if "xlApp.Visible" is set to True, it can be executed.
Is there any operation that does not work when the "Excel.Application.Visible" property is set to False?

The execution environment is Windows Server 2019 and Excel is 2016.

Dim xlBookRead1 As Excel.Workbook = Nothing
Dim xlBookCopy1 As Excel.Workbook = Nothing
Dim xlSheetsRead1 As Excel.Sheets = Nothing
Dim xlSheetsCopy1 As Excel.Sheets = Nothing
Dim xlSheetCopy1 As Excel.Worksheet = Nothing
Dim xlSheetHidden As Excel.Worksheet = Nothing

xlApp = New Excel.Application()
xlApp.Visible = False
xlBooks = xlApp.Workbooks

xlBookRead1 = xlBooks.Open("<Real Path>")
xlSheetsRead1 = xlBookRead1.Worksheets

xlBookCopy1 = xlBooks.Open("<Other Real Path>")
xlSheetsCopy1 = xlBookCopy1.Worksheets
xlSheetCopy1 = xlSheetsCopy1("TESTSHEET")

xlSheetCopy1.Copy(After:=xlSheetsRead1(xlSheetsRead1.Count))

xlSheetHidden = xlSheetsRead1(xlSheetsRead1.Count)
xlSheetHidden.Visible = Excel.XlSheetVisibility.xlSheetHidden

xlBookRead1.Save()

xlSheetCopy1 = Nothing
xlSheetHidden = Nothing
xlSheetsCopy1 = Nothing
xlSheetsRead1 = Nothing

If xlBookRead1 IsNot Nothing Then
      xlBookRead1.Close()
End If
xlBookRead1 = Nothing

If xlBookCopy1 IsNot Nothing Then
     xlBookCopy1.Close()
End If
xlBookCopy1 = Nothing

I'm using a translator, so I apologize if there are any strange sentences.
Thank you for your support.

Developer technologies | Visual Basic for Applications
{count} votes

Accepted answer
  1. Steve Gillard 76 Reputation points
    2022-06-16T14:11:17.523+00:00

    Hello,

    I got the same issues with Office 2010.
    I think the problem came from Windows SRV 2019 because on my 2008 server the Excel application can run without problem.

    Do you find a way to avoid the Win SRV 2019 problem ?

    Thanks,
    Steve.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.