Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2023, 07:49 AM
MrXDev MrXDev is offline How can I switch to/from "Focus Mode" with VBA? Windows 11 How can I switch to/from "Focus Mode" with VBA? Office 2021
Novice
How can I switch to/from "Focus Mode" with VBA?
 
Join Date: Mar 2023
Posts: 2
MrXDev is on a distinguished road
Default How can I switch to/from "Focus Mode" with VBA?

Hi All,



I would like to switch to "Focus Mode" (Word's distraction-free, full screen view) with VBA code. I've done a bunch of Google searches and have had no luck.

Any assistance would be very appreciated.

Thanks in advance!

MrXDev
Attached Images
File Type: png WordFocusMode.png (25.4 KB, 33 views)

Last edited by MrXDev; 03-08-2023 at 10:09 AM. Reason: add file
Reply With Quote
  #2  
Old 03-08-2023, 08:15 AM
gmayor's Avatar
gmayor gmayor is offline How can I switch to/from "Focus Mode" with VBA? Windows 10 How can I switch to/from "Focus Mode" with VBA? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,136
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Do you mean reading layout view?
Code:
ActiveWindow.View.ReadingLayout = True
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 03-08-2023, 08:26 AM
MrXDev MrXDev is offline How can I switch to/from "Focus Mode" with VBA? Windows 11 How can I switch to/from "Focus Mode" with VBA? Office 2021
Novice
How can I switch to/from "Focus Mode" with VBA?
 
Join Date: Mar 2023
Posts: 2
MrXDev is on a distinguished road
Default

Hi. Thanks for the reply.
No, I'm looking for the full-screen, distraction-free editing mode

Screen shot:
Microsoft services
Reply With Quote
  #4  
Old 06-22-2023, 02:41 AM
PatrickOfLondon PatrickOfLondon is offline How can I switch to/from "Focus Mode" with VBA? Windows 11 How can I switch to/from "Focus Mode" with VBA? Office 2016
Novice
 
Join Date: Oct 2022
Posts: 4
PatrickOfLondon is on a distinguished road
Default More information to hunt this down

Hi,

I have the same problem -- can't find a way of entering this view type from VBA.

In case it might help others to help us, MrXDev (and I) want to use VBA to get to the view you reach manually in Word when you:

-- click on the View tab on the ribbon

-- in the Immersive group on the View ribbon, click Focus

Can anyone help please?
Reply With Quote
  #5  
Old 05-17-2024, 05:04 PM
joShu joShu is offline How can I switch to/from "Focus Mode" with VBA? Windows 10 How can I switch to/from "Focus Mode" with VBA? Office 2019
Novice
 
Join Date: Apr 2021
Posts: 2
joShu is on a distinguished road
Default

I haven't been able to figure this out either.
The lines you get if you record a macro don't work for me.
Nor does something like Application.CommandBars.ExecuteMso "FocusMode" .
The best i have come up with so far is using sendkeys, which is clunky/dicey, but it does mimic the ribbon nav of Alt W O:

Code:
SendKeys "%wo"
Reply With Quote
  #6  
Old 05-18-2024, 04:17 AM
Guessed's Avatar
Guessed Guessed is offline How can I switch to/from "Focus Mode" with VBA? Windows 10 How can I switch to/from "Focus Mode" with VBA? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

joshu was very close to hitting the right command name
Code:
Application.CommandBars.ExecuteMso "ViewFocusModeView"
To figure out the name of the command which didn't appear in any of my usual searches, I went to the Customise Ribbon dialog and hovered over that particular button. A tooltip popped up with the actual command name shown in brackets.
Attached Images
File Type: png Screenshot 2024-05-18 211412.png (55.5 KB, 25 views)
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #7  
Old 05-18-2024, 05:07 AM
Italophile Italophile is offline How can I switch to/from "Focus Mode" with VBA? Windows 11 How can I switch to/from "Focus Mode" with VBA? Office 2021
Expert
 
Join Date: Mar 2022
Posts: 535
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by Guessed View Post
To figure out the name of the command which didn't appear in any of my usual searches
You can also get a complete list of control ids as an Excel workbook from GitHub - OfficeDev/office-fluent-ui-command-identifiers: Office Fluent User Interface Control Identifiers
Reply With Quote
  #8  
Old 05-18-2024, 05:19 AM
Guessed's Avatar
Guessed Guessed is offline How can I switch to/from "Focus Mode" with VBA? Windows 10 How can I switch to/from "Focus Mode" with VBA? Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,158
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Good call
I looked in my Word2016 version of that workbook and it wasn't there. I followed your link and found there is now a Word2019 version available and that command appears in that version.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #9  
Old 05-27-2024, 01:25 AM
PatrickOfLondon PatrickOfLondon is offline How can I switch to/from "Focus Mode" with VBA? Windows 11 How can I switch to/from "Focus Mode" with VBA? Office 2021
Novice
 
Join Date: Oct 2022
Posts: 4
PatrickOfLondon is on a distinguished road
Default

To "Guessed", and everyone else who has contributed so far, thank you for helping by identifying:

Application.CommandBars.ExecuteMso "ViewFocusModeView"

and the route to finding it.

To get to its neighbour in the "View > Immersive" group (the Immersive Reader view) using VBA, it's the rather more cryptically named:

Application.CommandBars.ExecuteMso "ToggleLearningTools"

which works in my Office 2021, and might in some earlier versions, too.

Last edited by PatrickOfLondon; 05-27-2024 at 01:29 AM. Reason: removing stray comma
Reply With Quote
  #10  
Old 02-24-2025, 11:48 AM
joShu joShu is offline How can I switch to/from "Focus Mode" with VBA? Windows 10 How can I switch to/from "Focus Mode" with VBA? Office 2019
Novice
 
Join Date: Apr 2021
Posts: 2
joShu is on a distinguished road
Default

Application.CommandBars.ExecuteMso "ViewFocusModeView" was the ticket, thanks Guessed. That is an easy way to toggle Focus Mode.

Now wondering if I can detect which mode I am in (in order to display Nav Pane, change Page Color, etc., based on mode)

I know I can do something like this for Print View:

Code:
test1 = ActiveWindow.View.Type = wdPrintView
But I have not yet found a similar technique for determining Focus Mode.

The use of ExecuteMso implies there is no object for it?

CommandBars.ExecuteMso method (Office) | Microsoft Learn
Quote:
This method is useful in cases where there is no object model for a particular command.
Reply With Quote
Reply

Tags
distraction-free, focus mode



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I switch to/from "Focus Mode" with VBA? Remove toggle button "focus" (dotted inner border) using VBA Matt C Excel Programming 7 05-22-2022 04:32 AM
Excel 2003: VBA "Function" causes "#VALUE!" errors after running "insert/delete row" custom macro Matt C Excel Programming 2 01-08-2022 06:03 AM
How can I switch to/from "Focus Mode" with VBA? Using "draw"tab crashes word- safe mode fixes temporarily? owl Drawing and Graphics 11 10-04-2017 10:11 AM
"one click" function to switch between branded presentations davidolone PowerPoint 0 01-16-2016 01:54 PM
How can I switch to/from "Focus Mode" with VBA? PPT 2010 Action - Run Program reverses "/" switch character wflett PowerPoint 4 03-17-2015 04:03 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:32 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft