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'?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Is it always the same workbook and if so what is the file path to the workbook?
 
Upvote 0
No - in the programme the file path is 'selected' using list boxes on a userform, but I cannae even make it work with a 'fixed' workbook.
 
Upvote 0
This is a code that will open up a workbook with a fixed file path. You'd have to put in whatever file path you use. Do you have any cells that reference the determination in filepath. Does the file path completely change? for instance is it always C:\mydocuments/workbook name or is it c:\mydocuments for one and then c:\user for another haven't really messed with list boxes
Code:
Sub Open_Workbook()
 
    Dim destWB As Workbook
    Workbooks.Open "C:\Users\mholt\Dropbox\Quality Control\Asphalt\Misc\Yearly HMA Charts.xlsx"
    Set destWB = ActiveWorkbook
 
 
 
 
End Sub
 
Upvote 0
jon - I cannot see what that achieves? It just opens the workbook on the taskbar. Have I missed something?
 
Upvote 0
If you run it as a macro using a keyboard shortcut that you assign to it, like control W, it opens it and makes it the active workbook you're staring at
 
Upvote 0
Without the other information that I asked about, the best i can do is to tell you to make that several macros, each with their own filepath, and assign different keyboard shortcuts to them.
 
Upvote 0
Are you saying that when YOU run that, 'destWB' opens on screen and not minimised on the taskbar? If so. I must have a problem with the Excel 2016 installation.

How do you manage without brackets around the file name in your code?

Anyone else?
 
Upvote 0
Code posted by jondavis1987
Code:
Sub Open_Workbook()
 
    Dim destWB As Workbook
    Workbooks.Open "C:\Users\mholt\Dropbox\Quality Control\Asphalt\Misc\Yearly HMA Charts.xlsx"
    Set destWB = ActiveWorkbook
 
 
 
 
End Sub
Just curious if you were trying to create event procedure code here (I cannot tell for certain if that is what you were intending or not).
If so, then the first line should be:
Code:
Private Sub Workbook_Open()
not
Code:
Sub Open_Workbook()
It will not run automatically if not named properly.

If you weren't intending it to be event procedure code that runs automatically, then my apologies...
 
Last edited:
Upvote 0
The Code runs properly for me and opens it up right in front of me where I can start working on it. There's nothing else in the code that I use there. I took it from a workbook where i have a lot more going on, opened up a workbook I use just for trying out macros, put just that in there, assigned a keyboard shortcut, and it opens directly.
 
Upvote 0

Forum statistics

Threads
1,214,925
Messages
6,122,303
Members
449,078
Latest member
nonnakkong

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