ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unhiding workbook when loaded (https://www.excelbanter.com/excel-programming/289611-unhiding-workbook-when-loaded.html)

John H[_4_]

Unhiding workbook when loaded
 
In Microsoft Word, using VB, I write to an Excel workbook. When I go to Excel and load the workbook, all sheets are hiden (I have to manually unhide the whole workbook). I have been trying to find a way to unhide the workbook, either before saving from Word or when it is opened in Excel

Here is the sequence
1. Load a Document in Word - on opening the document, my VB runs displaying a userform. When the "Save" command button on the userform is clicked, the Word document is saved (using a different name)

2. Still in the "Save" command button function, I then save the data to an Excel spreadsheet (across an intranet connection) using the following code to access it

Set WorkBook = GetObject("S:\TWI FORMS\data-Intro to Job Skills.xls"
Set myWorkSheet = WorkBook.Sheets("by date"

After writing in the data, I close the workbook using the following code

WorkBook.Sav
Set myWorkSheet = Nothin
Set WorkBook = Nothin

3. After closing Word, I open Excel and load the Workbook. I get the "Enable Macros" screen and click "Yes," but there is no indication that the workbook has even been loaded -- the whole WorkBook is hidden. You have to unhide it before you can get to the VB editor

I have put a popups (MsgBox) as the first line of functions to show that it was being run (since breakpoints cannot be saved) such as App_WorkbookOpen (and other subs meant to run on opening a workbook), but they never show. Also, Workbook.Worksheet.Visible = True does not work from Word (compile error)

I think the above subs are not being accessed because the workbook is still hidden

Thanks. This has been driving me crazy

John






MatthewT[_6_]

Unhiding workbook when loaded
 
I have only worked with hiding and unhiding worksheets but this seems t
work.

You must have a subroutine called

Code
-------------------

sub Workbook_Open()

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

This will run whenever the workbook is opened. You then need a line o
code to actually unhide the workbook. This seems to work:

Code
-------------------

Windows("YourWorkbookName.xls").Visible = True

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


--
Message posted from http://www.ExcelForum.com


John H[_4_]

Unhiding workbook when loaded
 
That worked. Thank you

John


All times are GMT +1. The time now is 11:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com