Windows 7 automation: Screen Resolution - Set Monitor as main display

From excel, and using the terminology of ControlPanel// Display/ Screen Resolution, how do I use code to set my PC laptop's screen as the MAIN DISPLAY?

My project uses an extension screen, and I must ensure that the property of 'Main Display' is not altered when I use automation to fit the dimensions of office Application windows to their respective screens.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kelvin4Author Commented:
Sorry! My references (above) to automation and code served to indicate the need for a programming solution.
Lionel MMSmall Business IT ConsultantCommented:
What do you mean by "from excel"?
Are you looking for something like this *link removed*. and have you tried the Windows Key + P?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kelvin4Author Commented:
Thanks lionelmm,  this HELPS ME...

Firstly, just to clarify, I run excel, plus an instance of the MS Visio application in early binding to the excelApp.  An extension monitor is added to my laptop PC and, via vba, I can automatically re-position the excel and visio app windows, and user forms, so they present a tidy layout to the user.

However, the code supporting this re-positioning requires that the PC laptop monitor is the MAIN Monitor of the two.
Vba function  MonitorEnumProc, DETECTS if the extended monitor is the main monitor, but I dont have the code procedure to RE_SET the PC laptop monitor as the MAIN MONITOR, whilst KEEPING the DUAL-monitor setup in use.

YOUR LINK to stackoverflow is very interesting. I found that Windows 7 key + P always sets the laptop monitor as the MAIN monitor, even if the extended monitor was previously the main monitor. SO! I'd like to try to use it for the above!

Please can you help me for one more step? In the stackoverflow answer:

DisplaySwitch.exe /external
   ..... this batch file [will] open notepad and it will always open and switch to the external display only.
(actually I have never made a batch file).... but..... I guess that the following will switch to the extended monitor setup with laptop monitor as main monitor:

DisplaySwitch.exe /extend

I dont know how to write a batch file, and I need to use the SWITCH function in real time, when excel is being used.
Can I use a batch file for that, or should I write a different sort of module code procedure?

Many thanks indeed for your help
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Kelvin4Author Commented:
Hi Gerwin:
Thanks - that's kind.
I did read and respond to that that comment (Kelvin42015-04-02 at 17:11:08ID: 40703397).
Useful progress has now been made with another expert.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
You don't need a batch. Just call the tool with the Shell command:
  Shell displayswitch /external

Open in new window

Kelvin4Author Commented:
Thanks for quick support and new information.
Lionel MMSmall Business IT ConsultantCommented:
Kelvin--glad to help--you said the the response was quick and was what you wanted so may I ask why only a grade of B? Thanks!
Kelvin4Author Commented:
Glad you got back to me.
I guess A is quasi-exceptional in my background.
But Expert enthusiasm is what I depend on, so I will ask the Admin to boost the last rating to A. With appreciation!

Not sure if that will be effective in correcting the underscore, but I do hope the changed rating comes through.

Best regards and thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.