How can I ensure that the "details" task pane in microsoft project vba is NOT displayed - vba

I have an application in Microsoft project that performs a Backtrace of a task and then uses the following to save that image to an Excel Tab
Application.EditCopyPicture Object:=False, ForPrinter:=0, SelectedRows:=0, FromDate:=EarliestStart, ToDate:=LFin, ScaleOption:=pjCopyPictureShowOptions, MaxImageHeight:=-1#, MaxImageWidth:=-1#, MeasurementUnits:=2
definitions for msome of the variables used in the procedure:
EarliestStart = StatusDate-30
Lfin = Finish of the target Task for the Backtrace, which would be the last task in the string.
I use a flag field to identify tasks that I want to create a backtrace for and then cycle through all the tasks to create the Backtrace images and saving them to a unique excel tab.
Every so often, my app "creates a secondary task pane" using the same view that I am using in the top half of the split screen. I do not want a split screen with the bottom half of the screen displayed. When I have a split screen, my application
Is there a vba command that I can use in code that will test for the presence of a secondary task pane and if present, clear it. I have been looking for something that would test the Ribbon task\details checkbox but have been unable to find it.
If before running the application I remove the secondary pane, it runs fine. If I start to run the vba with a secondary pane showing, it brings up a View "View" dialog.
I have experimented with:
ViewApplyEx SinglePane:=True, ApplyTo:=1
but this displays the View"Views" dialog and forces me to select a view from the list, which is not what I want to do.
Any suggestions as to where I should look?

The method you are looking for is PaneClose. It will close the lower pane of the active window. It does nothing if the lower pane was already closed. So do this:
Application.PaneClose
Application.EditCopyPicture Object:=False, ForPrinter:=0, SelectedRows:=0, FromDate:=EarliestStart, ToDate:=LFin, ScaleOption:=pjCopyPictureShowOptions, MaxImageHeight:=-1#, MaxImageWidth:=-1#, MeasurementUnits:=2

Related

Manipulate the MS-Word Navigation Pane via VBA-Macro [duplicate]

I am trying to write a VBA macro that runs when opening a .docx document. I want it to force the display of the Navigation Pane and then force all of the headings (any level) to display in collapsed mode. I am trying to get the code for the Collapse command using the macro recorder.
All I have when I record the macro is:
ActiveWindow.DocumentMap = True
Right-clicking on a heading in the Navigation Pane and collapsing does not record a code line. Is there a VBA method for this event?
I "solved" this requirement for myself by means of an AutoHotKey script, which just sends the necessary mouse click and subsequent key strokes. Not beautiful, but it works most of the times.
Kind regards, Hauke
As of this writing in 2019, this is not possible through VBA. It's been asked for from Microsoft for a long time.
As originally suggested in this Microsoft forum post, the quickest way to collapse all of the headings in the Navigation pane is to right-click one of the headings and click Collapse All. Obviously this is not an automated/macro-based solution, but it's all we have until Microsoft exposes the task panes through the VBA object model.

AppleScript -- Menu Item in the Menu Button popup is not selectable while using keystroke return or (key code 36) command

I have gone through stack overflow, this might seem like a duplicate question but this is more like an extended question to the existing issue!
I am facing a very strange issue, in my application we have customised the pop up button (Inheriting from NSPopupButton).
When I use Apple Script to access the pop up item, the script is not able to select any value from the popup list.
Let me be more clear!
For eg.
Imagine the Popup button has "Car, Bike, Cycle, Bus" as its items. Now if I use AppleScript to select Bike and then click enter, the value is not getting reflected. But manually if I select "Bike" it will reflect in the application.
This is the script that I wrote.
click menu button "Car" of window 1 of application process "My Sample Application" of application "System Events"
key code 125 //I am using these to navigate down the list
delay 1
key code 125 //I am using these to navigate down the list
delay 1
key code 125 //I am using these to navigate down the list
delay 3
key code 36 //This line simulated ENTER/Return key (or NOT?)
I have also tried running this command in Apple Script
--set xxx to value of every button of menu button "Car" of window 1 of application process "LG Calibration Studio" of application "System Events"
This command was suppose to show me all the items present in the Popup, but unfortunately it is returning an empty array(or Dictionary). Even though the pop up is populated with values I am not sure why this is returning empty.
I am kind of new to Apple Script and do not have much knowledge in this domain. Any help is appreciated.
Thanks in advance :)
When using UI scripting, the relationships between ui objects is not always clear. I'll use Apple's Pages (as it's freely available — I use an untouched 'Essay' document) as an example. Here are two suggestions to explore. If they make sense, you can try similar actions with your own app.
UI Elements command
In a new script…
tell application "Pages"
-- activate -- Not necessary until you want to act upon the window
tell application "System Events" to tell front window of application process "Pages"
UI elements -- generate list of window's ui elements
properties of splitter group 1 -- the first element in the list (branch 1)
UI elements of splitter group 1 -- generate list of first branch
-- entire contents
end tell
end tell
Partial result of command 1
{splitter group 1 of window "Untitled" of application process "Pages" of application "System Events", button 1 of window "Untitled" of application process "Pages" of application "System Events", button 2 of window "Untitled" of application process "Pages" of application "System Events"}
Partial result of command 2
{minimum value:missing value, orientation:missing value, position:{40, 22}}
Partial result of command 3
{scroll area 1 of splitter group 1 of window "Untitled" of application process "Pages" of application "System Events", static text "0 Comments & Changes" of splitter group 1 of window "Untitled" of application process "Pages" of application "System Events", button "Comment" of splitter group 1 of window "Untitled" of application process "Pages" of application "System Events"}
Using ui elements you can work your way through the myriad interface objects in your window. You can also ask for specific properties, e.g. name of every pop up button. Finally, you can get a list of all ui elements with entire contents.
Accessibility Inspector
Using the application Accessibility Inspector, you can inspect the window and discover its elements. This is located inside XCode's app bundle and is also accessible through the XCode > Open Developer Tool menu.
It changes with the version of XCode so there isn't any point in getting too detailed (I'm on Xcode 9) but once it is launched, click on the 'All Processes' drop down button at the top left and it should list the open apps; select Pages from this list.
A couple of things to note: At the bottom is the hierarchy of elements which can help in determining which object to act upon. Each line's bracketed text references the class of object but the text isn't always literal (e.g. your script should use 'window' not 'standard window').
If you use the 'pointer' and then in Pages, click on the empty area at the bottom of the Format inspector, the hierarchy will show a long list of items under (scroll area). Also, there are various ways to interact with an interface object, of which 'click' is but one.
If I insert this code into the script and then select the body text, the script will format the selection as italics (which matches the hierarchy entry 'Regular (pop up button)', with 'Regular' being the selection's existing font format.
tell pop up button 2 of scroll area 2 of splitter group 1 of ¬
window "Untitled" of application process "Pages" of ¬
application "System Events" to perform action "AXPress"
delay 0.5
keystroke "i"
key code 36
Hopefully, utilizing these two approaches may yield some useful results before the onset of ui scripting headache.

Word 2013 activate "New" screen from VSTO

I'm developing a Word AddIn, and I've run into a bit of a problem.
I need to modify the BuiltIn BuildingBlocks, and to do that, I need an active document.
Since Word 2013 no longer starts with an open document, but instead shows the "New (Latest)" screen, my AddIn creates a new temporary document, modifies the BuildingBlocks as it should, and then discards the temporary document.
The problem is that the act of opening a new document and closing it again, leaves the Word UI at the Home-tab with no active document open, instead of on the "New" screen as it normally would.
So my question is: How do I make Word switch back to the "New" screen?
Here is the before screen, showing normal Word 2013 behaviour on startup:
Here is the after screen, showing how it ends up now, because I open/close the document at startup:
Sorry about the danish screenshots, but the principle should still be clear.
I'm using VB.Net, but C# code can be used too, since it is easily translated.
There is no way to show the Startup screen again. Instead, you may consider running a new Word instance.
Be aware, the Word object model provides the ScreenUpdating property of the Application class which you may find helpful. Here is what MSDN states:
The ScreenUpdating property controls most display changes on the monitor while a procedure is running. When screen updating is turned off, toolbars remain visible and Word still allows the procedure to display or retrieve information using status bar prompts, input boxes, dialog boxes, and message boxes. You can increase the speed of some procedures by keeping screen updating turned off. You must set the ScreenUpdating property to True when the procedure finishes or when it stops after an error.
You may also create a template file with building blocks, then attach the template on top of the new document
It will solve you problem

Deleting menu item results index error ("source not found")

In VB.Net 2010, whenever I delete a menu item on a Windows Form (a Mainmenu1 object), an exception is thrown at run-time suggesting that there is an index value missing -- essentially a "source not found" error. Do I need to go into the Mainmenu1 object on the bottom of the Form at design time and do something? (BTW, I have also tried deleting the source code for the menu item, and then the menu item, and the exception is still thrown).
Basically, something is occurring that is not allowing me to simply delete a menu item, and get a successful run thereafter.
I had this problem. The simple fix is to restore the menu by clicking undo. Then run the code to make sure it still works. When you have done this, CLOSE visual studio. Then open VS and load your project. Delete the item from the menu and run the project. Everything should be fine
I think you need to specify whether you were trying to delete the menu or menu item during run time, or during design time.
You said, an exception, indicating an index value was missing, thrown at run time. I think it might be depending on how you deleted the menu item. You didn't mention how you deleted the menu item.
Normally, when you choose a menu item from a menu at design time, and press the Delete key, it disappeared. And, the program still works fine.
And, another possibility, is that your form window designer and the background designer code is not properly synced.
You might know that, every .NET form objects, have their background designer code, which serves as a schema for everything on the form.
When you add a button onto the form, the Visual Studio add a line of code in the designer code file (normally if your form name is form1, the designer code file is form1.designer.vb or cs or whatever). When you change the background colour of the button, designer code file add a line of code to set the button's background colour.
So, you see, in your case, when you delete the menu item, your designer code file probably didn't successfully remove the code relating to that menu item. So, it throws an exception at run time.
Maybe, it's because of your Visual Studio installation.
So, my suggestion is, you should try debugging the project, line by line, by running the project with F6 or F11 (sorry, I don't remember the exact key, but you can find it in the Debug menu).
I hope I made a good sense for your problem!

System.Threading.ThreadstateException

I'm developing an adding for office powerpoint application.
I'm trying to display a description of the object(Customized object) currently dropped on the powerpoint slide in design mode(Design mode of the powerpoint).
When i click on my addin the related object description will be displayed on a tabbed window as the first tabpage.
There is a button on the tab page, and when i click on it i need the description to get copied to windows clipboard.
I tried this using clipboardclass it throws the following exception,
System.Threading.ThreadstateException
{"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."}
Code for clipboard:
Clipboard.Clear()
Clipboard.SetText(lblObjectID.Text)
I searched the net for a solution and got couple of answers like,
1. Put [STAThread] in the main function
2. Thread.CurrentThread.SetApartmentState(ApartmentState.STA) Immediately before your call to SetDataObject.
But I'm not sure where to put the 1st one and the 2nd option didn't work.
Can anyone help me please.
Thanks.
WinForms are STA by default. Are you creating another thread or using a BackgroundWorker? Run this code to determine what mode you're in:
MessageBox.Show(System.Threading.Thread.CurrentThread.GetApartmentState().ToString())
Edit:
But maybe you could also try using this command before calling the clipboard functions:
Application.OleRequired()