hide a workbook with macro

T

txaggies07

I am currently working on a project that involves several hidden
workbooks to be open. I have a script that switches these files out
based on a selection. The files have to be closed in order for the
switch to take place since it is copying a background file to become
the actual file. So anyways, I have the script working to close the
workbook, copy, paste, and open the workbook. However, the workbook
always comes up as unhidden. I need to write in to the code that it
needs to hide itself.

My code looks like this (Some code may look familiar because I have had
some help from this group):

HomeFolder = ThisWorkbook.path & "\background\Bus Modules\"
ToFolder = ThisWorkbook.path & "\background\"
Set FromSheet = ActiveSheet
FromRow=3
While FromSheet.Cells(FromRow, 5).Value <> ""
If FromSheet.Cells(FromRow,6) = "x" Then
FromFileName = HomeFolder & FromSheet.Cells(FromRow, 5).Value
ToFileName = ToFolder & "Bus" & ".xls"
Workbooks(FileName).Save
Workbooks(FileName).Saved = True
Workbooks(FileName).Close
FileCopy FromFileName, ToFileName
Workbooks.Open FileName:=ToFileName, UpdateLinks:=0
End If
FromRow = FromRow + 1
Wend



I need the addition to go at the last line of the While Statement to
hide the workbook.



Thank you,
Aaron
 
B

Bob Phillips

Try adding

activewindow.Visible=true

after the workbook open.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top