Unhiding workbook when loaded

J

John H

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
 
M

MatthewT

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
 

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