FormViewShow is generating the following error when run in my VBA module:
There is not enough memory to complete the operation. To free up available memory, close programs, projects, or windows you aren't using, then try again.
This is followed by:
Run-time error 1004. An unexpected error occurred with the method.
FormViewShow runs successfully if in the Gantt view. However if I run a report (e.g. Milestone Report), then FormViewShow generates these errors. This worked in Project 2010 and earlier. It started happening for me in Project 2013.
I'm trying to find a way to close the bottom pane. ActiveWindow.BottomPane.Close works in Gantt view, but not when viewing a report (it closes report, not bottom pane). FormViewShow used to work. DetailsPaneToggle at least doesn't generate an error. Ultimately I want a way to detect if there's two panes visible and close the bottom one. Any suggestions? Also, I think FormViewShow is a bug but not sure how to report this to Microsoft.
I suspect you need to make sure a none report view is active before running the macro. As a start, can you do what you want the macro to do manually with a report active? If not, then VBA can't either.
Rod Gill Project Management
Yes, I can do what I want to do manually. Basically I have a split screen with both top and bottom panes visible. In any view (Gantt, report, etc.), I can just right-click and uncheck "Show Split" in the context menu. This closes the bottom pane.
My problem is doing this with VBA. I have code that runs anytime a view is changed (App_WindowViewChange event). The code will close the bottom pane whenever the view is changed. I've tried these options below but not with complete success.
Ideally, I want to query if the bottom pane is visible and close it. I've never found anything reliable that would tell me if the bottom pane is visible. I've seen suggestions that say "If FormViewShow Then FormViewShow", but that has never worked. The only workaround I found was to run "FormViewShow" twice. I would have thought that would just toggle it off/on and put me back to the original state, but somehow that always worked until Project 2013.
Here's what happens now in VBA:
1. FormViewShow (twice) - This worked in Project 2010 and earlier, but now get out of memory error if in report view in 2013. This looks like a bug to me.
2. DetailsPaneToggle - This works for Gantt view, but toggles the top pane instead of the bottom pane for a report. I thought I could set focus to the bottom pane (i.e. ActiveWindow.BottomPane.Activate) and then execute DetailsPaneToggle, but that doesn't work. I also tried executing the command twice, but that ended up putting the code in an infinite loop.
3. ActiveWindow.BottomPane.Close - This seemed like the best solution, but it only works in Gantt view. It closes the top pane instead of the bottom pane if viewing a report. This also seems like a bug in 2013.
If you have any suggestions, I'd love to get this working in 2013. All I want to do is:
Query if bottom pane is visible
Close bottom pane
Seems simple, but I can't figure out how to do it.
Try making top pane active, then use ActiveView to record teh view's name. Then do the bottom pane close option (number 3) and re-apply the original top pane view.
I know it's a work around, but probably simplest option for now.
Rod Gill Project Management
Thanks for the reply. I wasn't exactly sure what you meant to do, but did discover something while trying your suggestion. When I have two panes with a Gantt view, the top pane that I see in the UI is the name of the top pane when I query it in VBA. However if I run a report (e.g. Milestone report). the report is visible in the top pane in the UI but the name is in the bottom pane when I query it in VBA. I don't know why, but VBA is reporting the names flipped (i.e. top is bottom and bottom is top) for reports. Gantt views are fine, but reports are backwards. This is compounding my problems. I have some ideas to work around this along with your suggestions, but it's starting to get ugly.
I'm not an expert by any means, but I'm convinced there's several bugs in 2013. I probably need to report this to Microsoft and stop pulling out my hair.
Rod,Thanks for helping. I really appreciate it. This should be simple. It could be user error, but I'm perplexed and can't see a solution. Here's the steps to reproduce my dilemma:
1. Open MS Project.
2. In Gantt Chart view, split screen (i.e. right click, Show Split). You should have Gannt Chart in the top pane and Task Form in the bottom pane.
3. In Ribbon, go to Report, In Progress, Milestone Report. You should have a split screen with the report on top and Task Form in the bottom pane.
4. In the UI, remove the split (i.e right click, uncheck Show Split). Notice how the split is removed and you now only see the Milestone Report. This is what I want to do programmatically.
Now try the same thing using VBA. Repeat steps 2-3 above so that you have the Milestone Report at the top and Task Form at the bottom. Try closing the bottom pane using these methods:
1. Type ActiveWindow.BottomPane.Close in the VBA Immediate window. Notice how this closes the top pane with the report and not the Task Form.
2. Type FormViewShow in the Immediate Window. This also closes the report (top pane). I can also cause an out of memory condition, but that's another problem for another day.
3. Type DetailsPaneToggle in the Immediate Window. This works correctly. However if the window isn't split, this will cause the screen to split which I don't want. Thus, I need to query if the screen is split first and only execute DetailsPaneToggle if it's already split. My goal is to have no split after running the report.
I can't figure out how to tell if the screen is already split. I can toggle it, but don't know the current state. I've tried activating both panes so I'd know they're both visible, and then close the bottom pane. The problem seems to be that the Milestone Report isn't a view and possibly not in either the top or bottom pane. Although it looks like the top pane, I suspect it's not really in the top. There's something weird here and can't figure it out. I don't want to hard code any names of views, reports, or similar so this will work with any report.
Thanks for any help you can give me.
As suggested before I think you need to use version specific code. If 2013 then record the ActiveProject.CurentView, close the bottom pane then reapply the View.
This is a bug, but it's small and there's a work around so I doubt there will be a quick fix.Quickest way to get a response is to raise a support request with Microsoft.
I did notice that if I make the Report active and in the immediate window enter:
I get 2
If the Gantt chart is active in the top pane it returns 1. I suspect this may be part of the problem.
I'll report this to the team.
- Edited by Rod GillMVP, Moderator Wednesday, September 25, 2013 10:47 PM
I managed to find a way to work around the problem. It's not as simple as having 2013 specific logic. The pane that needs to be closed depends on which type of view has been applied (e.g. Gantt vs. report). The method to close a pane also doesn't work properly depending on the type of view. There's no way to determine if the pane you want to close is visible, so you just can't toggle it. I managed to do this using error handling. It should also work for any version since some of this was also an issue in 2010 and earlier, just not as badly.