Type mismatch?

  • Thread starter Thread starter sue
  • Start date Start date
S

sue

HI all,

When I run this code it dies with a "Type Mismatch" error:

If
Worksheets(ThisWorkbook.CustomDocumentProperties.Item("System_1")).Visible
= xlSheetVisible Then

Worksheets(ThisWorkbook.CustomDocumentProperties.Item("System_1")).Name
= "System_1"

Worksheets(ThisWorkbook.CustomDocumentProperties.Item("System_1")).Visible
= xlSheetHidden

ThisWorkbook.CustomDocumentProperties.Item("System_1") = ""

End If

The odd thing is that the variable,
ThisWorkbook.CustomDocumentProperties.Item("System_1"),
is a string and is exactly the string needed to be placed within the
Worksheets()as a sheet index or name in the parenthesis. If I place a
string within the parens that is the same value as the custom property
it works fine...of course in that situation I do use quotes.


Thank in advance,

Susan
 
Sue,

Change
ThisWorkbook.CustomDocumentProperties.Item("System_1")
to
ThisWorkbook.CustomDocumentProperties.Item("System_1").Value
in all places.

HTH,
Bernie
MS Excel MVP
 
Bernie said:
Sue,

Change
ThisWorkbook.CustomDocumentProperties.Item("System_1")
to
ThisWorkbook.CustomDocumentProperties.Item("System_1").Value
in all places.

HTH,
Bernie
MS Excel MVP
Hmmm...I just assumed that "value" was the default property and in fact it would print out like it
was in a msgbox? But your suggestion works...thanks!

Susan
 
Sue,

Value may be the default property, but my guess is that it is being treated
as a variant until it is evaluated, which is too late when it is used as the
parameter.

Bernie
 
Back
Top