Display opened workbook on screen

mikjp

New Member
Joined
May 3, 2019
Messages
16
Excel 2010 & 2016: I would like to open a selected workbook and see it on screen to be worked with. At present it only loads in the taskbar. Is there way to code this or do I use Sendkeys to make it 'active'?
 
assigned a keyboard shortcut, and it opens directly.
Ah, that's the key right there. You are calling/running the code manually, from a keyboard shortcut.

Since your name was so close to the "Workbook_Open" event procedure (which is VBA code that runs automatically when that particular file opens), I wasn't sure if that was what you are intending, and just made a typo. It does not appear to be the case.

Sorry for the confusion.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Well, jon, I'm stumped. If I run this macro in "Book4.xlsm" in 2016 from the IDE on my machine, it ONLY opens "Book5.xlsx" on the taskbar.

Code:
Sub Open_Workbook()
Dim destWB As Workbook
    Workbooks.Open "Z:\Book5.xlsx"
    Set destWB = ActiveWorkbook
End Sub

Is it perhaps because you use an assigned key and I run it from the IDE?
Anyone?
 
Upvote 0
Bizarre! If I re-name the sub to Auto_Open it runs 'normally' when I open the host workbook. HOWEVER, if I run that sub in the IDE it does not.
 
Upvote 0
OK - you can all relax. Thanks to Stack Overflow I have the solution and 'cos I'm a decent guy I'll post it here for you all.:laugh:

A new instance of Excel is required.

Code:
    Dim xls As Excel.Application
    Dim wb0 As Excel.Workbook
    Set xls = New Excel.Application
    Set wb0 = xls.Workbooks.Open("blah blah", ReadOnly:=False)
    xls.Visible = True

Bingo!

Thanks, Stack!
Only two hurdles left to jump now
1) It opens 2 copies of the workbook ????
2) It opens not 'maximised'.

I'll get there.
 
Upvote 0
Try throwing this in there. I don't know why it would open two copies.

Code:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">[COLOR=#303336][FONT=inherit]    Application[/FONT][/COLOR][COLOR=#303336][FONT=inherit].[/FONT][/COLOR][COLOR=#303336][FONT=inherit]WindowState [/FONT][/COLOR][COLOR=#303336][FONT=inherit]=[/FONT][/COLOR][COLOR=#303336][FONT=inherit] xlMaximized [/FONT][/COLOR][COLOR=#858C93][FONT=inherit]'maximize Excel[/FONT][/COLOR][COLOR=#303336][FONT=inherit]
    ActiveWindow[/FONT][/COLOR][COLOR=#303336][FONT=inherit].[/FONT][/COLOR][COLOR=#303336][FONT=inherit]WindowState [/FONT][/COLOR][COLOR=#303336][FONT=inherit]=[/FONT][/COLOR][COLOR=#303336][FONT=inherit] xlMaximized [/FONT][/COLOR][COLOR=#858C93][FONT=inherit]'maximize the workbook in Excel[/FONT][/COLOR]</code>
 
Upvote 0

Forum statistics

Threads
1,223,757
Messages
6,174,331
Members
452,555
Latest member
colc007

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top