Link to home
Start Free TrialLog in
Avatar of itnifl
itniflFlag for Norway

asked on

Select tabs in Word with Powershell

I use Powershell to open Word this way:

$word = New-Object -ComObject word.application
$word.visible = $true

Open in new window


Now I would like to select the developer tab and hit the View Macros button by using the same powershell script.
How do I do that?
Avatar of aikimark
aikimark
Flag of United States of America image

What are you trying to accomplish once you are viewing the macros?
Avatar of itnifl

ASKER

You are looking for a workaround. I am not trying to accomplish anything but open this tab and hit the macro button. There is probably a way to code whatever you want to do in there, but at this given moment it is not going to be coded. I just want the tab and button to be pressed automatically. That's all.
There is no need to open the macro tab.  You have already instantiated a Word Application object in your PS code.  You only need to use that object's Run method.
https://msdn.microsoft.com/en-us/library/office/ff838935.aspx
Avatar of itnifl

ASKER

You are still looking for a workaround or a different way to the goal. Didn't say I was going to run the macro either. Ultimately the macro will be opened and signed, but like I stated, I am not interested in doing that by code right now. I want to see if there is a way to push that macro button.
Since this can get into the hacking realm really fast, I REALLY want to know the particulars.  I don't want to run afoul of EE's Terms of Use with respect to hacking/cracking.  The ambiguity in your response isn't helping assuage my concerns.

I am not looking for a work-around
Avatar of itnifl

ASKER

Thank you for your reply.
The question is not very ambiguous actually. It states that I want to know if there is a way to push a button on a Ribbon with Powershell.
That would be a part of an automation job. All actions are possibly malicious, so I guess your concern could be applied to many things.

After a bit googling I have found statements that automating ribbon clicks in Word is pretty hard to do.

I ended up with a workaround myself.

I used Auto-IT to open Word and hit ALT-F11. That opens the same destination as the button I was trying to push.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of itnifl

ASKER

Yup, does the trick in Powershell. Thanks!