SOLVED

MS Project VBA Default Location and Default AutoScheduled tasks

%3CLINGO-SUB%20id%3D%22lingo-sub-2964357%22%20slang%3D%22en-US%22%3EMS%20Project%20VBA%20Default%20Location%20and%20Default%20AutoScheduled%20tasks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2964357%22%20slang%3D%22en-US%22%3E%3CP%3EHello%2C%3C%2FP%3E%3CP%3EI%20have%20two%20VBA%20related%20questions%20for%20MS%20Project.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E1)%20How%20do%20I%20find%20the%20Default%20File%20Location%3F%3C%2FP%3E%3CP%3EIn%20Excel%20it%20is%20easy%20with%26nbsp%3BApplication.DefaultFilePath%20but%20I%20can't%20seem%20to%20find%20an%20equivalent%20in%20MS%20Project.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2)%20How%20can%20I%20set%20the%20default%20Task%20Mode%20to%20Auto%20Scheduled%20for%20all%20new%20projects%3F%3C%2FP%3E%3CP%3EI%20know%20how%20to%20do%20it%20in%20the%20manually%20in%20the%20options%20but%20I'm%20looking%20for%20a%20VBA%20approach.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20You%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2964357%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3E2016%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EProject%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2966107%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Project%20VBA%20Default%20Location%20and%20Default%20AutoScheduled%20tasks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2966107%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F920454%22%20target%3D%22_blank%22%3E%40Gilgamesh1964%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20default%20file%20path%20for%20save%20operations%20is%20controlled%20by%20the%20Project%20options%20setting.%20Unfortunately%20those%20settings%20are%20not%20readable%20directly%20as%20they%20are%20in%20Excel.%20I%20haven't%20tried%20this%20but%20it%20may%20be%20possible%20to%20get%20the%20default%20file%20path%20by%20creating%20and%20querying%20a%20FileSystemObject.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnother%20option%20is%20an%20indirect%20method%20and%20that%20is%20simply%20opening%20a%20file%20you%20know%20is%20in%20the%20default%20location%20and%20then%20using%3A%20ActiveProject.FullName%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOn%20your%20other%20question%2C%20for%20whatever%20reason%20the%20scheduling%20mode%20is%20not%20an%20exposed%20parameter%20when%20setting%20options%20using%20VBA.%20Sorry.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20helps.%3CBR%20%2F%3EJohn%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2967806%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Project%20VBA%20Default%20Location%20and%20Default%20AutoScheduled%20tasks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2967806%22%20slang%3D%22en-US%22%3EThank%20you%20for%20a%20quick%20response.%3CBR%20%2F%3EI%20will%20have%20a%20play%20around%20with%20FileSystemObject%20and%20see%20what%20I%20can%20get%20there.%3CBR%20%2F%3E%3CBR%20%2F%3EOn%20Auto%20Scheduling%2C%20It%20seems%20strange%20to%20me%20that%20something%20(in%20my%20opinion)%20is%20so%20important%20is%20not%20available.%3CBR%20%2F%3EDo%20you%20know%20if%20this%20is%20stored%20in%20a%20Registry%20Key%2C%20I%20may%20try%20making%20adjustments%20there%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20reason%20for%20the%20questions%20is%20that%20our%20IT%20department%20just%20installs%20an%20out-of-the-box%20version%20of%20MS%20Project%2C%20but%20our%20Project%20Office%20has%20some%20standards.%20I'm%20trying%20to%20automate%20setting%20those%20standards%20rather%20than%20relying%20on%20people%20who%20can%20make%20mistakes.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2967992%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Project%20VBA%20Default%20Location%20and%20Default%20AutoScheduled%20tasks%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2967992%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F920454%22%20target%3D%22_blank%22%3E%40Gilgamesh1964%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EIt%20is%20a%20little%20strange%20about%20the%20auto%2Fmanual%20scheduling%20option%20not%20being%20available%20via%20VBA%2C%20all%20the%20other%20scheduling%20options%20are.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYes%2C%20you%20can%20set%20auto%2Fmanual%20in%20the%20registry.%20This%20is%20what%20it%20looks%20like%20on%20my%20PC%2C%20which%20is%20currently%20set%20for%20auto%20schedule.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%222021-11-15_18-58-26.png%22%20style%3D%22width%3A%20778px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F327179i6C1C679B7215C222%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%222021-11-15_18-58-26.png%22%20alt%3D%222021-11-15_18-58-26.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EJohn%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hello,

I have two VBA related questions for MS Project.

 

1) How do I find the Default File Location?

In Excel it is easy with Application.DefaultFilePath but I can't seem to find an equivalent in MS Project.

 

2) How can I set the default Task Mode to Auto Scheduled for all new projects?

I know how to do it in the manually in the options but I'm looking for a VBA approach.

 

Thank You

7 Replies

@Gilgamesh1964 

The default file path for save operations is controlled by the Project options setting. Unfortunately those settings are not readable directly as they are in Excel. I haven't tried this but it may be possible to get the default file path by creating and querying a FileSystemObject.

 

Another option is an indirect method and that is simply opening a file you know is in the default location and then using: ActiveProject.FullName

 

On your other question, for whatever reason the scheduling mode is not an exposed parameter when setting options using VBA. Sorry.

 

Hope this helps.
John

Thank you for a quick response.
I will have a play around with FileSystemObject and see what I can get there.

On Auto Scheduling, It seems strange to me that something (in my opinion) is so important is not available.
Do you know if this is stored in a Registry Key, I may try making adjustments there?

The reason for the questions is that our IT department just installs an out-of-the-box version of MS Project, but our Project Office has some standards. I'm trying to automate setting those standards rather than relying on people who can make mistakes.
best response confirmed by Dale Howard (MVP)
Solution

@Gilgamesh1964,

It is a little strange about the auto/manual scheduling option not being available via VBA, all the other scheduling options are.

 

Yes, you can set auto/manual in the registry. This is what it looks like on my PC, which is currently set for auto schedule.

2021-11-15_18-58-26.png

John

Thank You for all your assistance.
I ran some code to edit the registry key which worked (I opened RegEdit to have a look t it) but when I closed MS Project it reverted to it's previous value :(

Looks like I will have to write some idiot-proof instructions for people to change this setting manually (and I'm sure someone will still mess it up)
Gilgamesh1964,
You're welcome and thanks for the feedback.

Strange. I've never tried to change the registry with code, I've only done it manually. Did you include in your code a line to save Project? I would think that would save the change to the GLobal.
John

@John-project 

Hi
Sorry for taking so long to get back (non schedule based project work got in the way :smile:).

No I hadn't added a line to save the project. I would have thought as I'm changing the default for new schedules then a save of the current one would not be necessary.

However I added one, and this is where we now enter the Twilight Zone.

New schedules were being created with Auto Scheduled tasks as desired. But when looking at the MS Project settings it was still showing Manual Scheduled as the default setting for new schedules ????

Changing this MS Project setting in the standard GUI interface no longer had any effect, I would set it for Auto Scheduled, Leave, and upon going back in it said Manually Scheduled again. Yet new schedules continued to be created as Auto Scheduled.

I managed to restore normal functionality by using RegEdit to restore the setting, and I think I'll stick with manual instructions to get this setting as desired.

Yeah I remember that episode, I think it was 1963. Oh well, you do what you have to do to make it all work :)
Thanks for the feedback.
john