Hiding WorkBook without specifying a file name


Posted by Stan on September 28, 2001 6:05 AM

I am using the following to hide a workbook

Windows("myFile.xls").Visible = False

If I save the file as "myNewFile.xls", I have to go through the code and change the file name. Is there a way that I don't have to specify "myFile.Xls"? Note: if there are other WorkBooks open, I don't want to hide them - only the one with the code.

Cheers

Stan

Posted by Juan Pablo on September 28, 2001 6:14 AM

Try

ThisWorkbook.Visible = False

Juan Pablo

--------------------

Posted by Barrie Davidson on September 28, 2001 6:16 AM

Stan, a familiar problem, I think I've read this somewhere before :)

Using a string variable name codeWorkbook, you can use:

codeWorkbook = ThisWorkbook.Name
Windows(codeWorkbook).Visible = False

Regards,
BarrieBarrie Davidson

Posted by Stan on September 28, 2001 6:34 AM

Thanks

Thanks guys.

Barrie - You helped solve my other problem last night. Thanks again.

Posted by Barrie Davidson on September 28, 2001 6:49 AM

Juan, it doesn't work for me

I tried using this one line of code and get a compile error "Method or data member not found". Any ideas why it doesn't work for me??

Barrie

Posted by Juan Pablo on September 28, 2001 7:03 AM

Re: Juan, it doesn't work for me

I didn't copy the entire thing, sorry

Windows(Thisworkbook.Name).Visible = False

It's the same, one line shorter, than yours.

Juan Pablo



Posted by Barrie Davidson on September 28, 2001 7:09 AM

Thanks Juan, nothing like learning something new !! (NT)

Windows(Thisworkbook.Name).Visible = False It's the same, one line shorter, than yours. : I tried using this one line of code and get a compile error "Method or data member not found". Any ideas why it doesn't work for me?? : Barrie :