none
mapedit fails when called from Visio, but works in Project RRS feed

  • Question

  • Hi - 

    I'm writing some vba code in Visio that 1. opens a selected Project file, 2. creates a Map, and 3. exports that map data to Excel. I've got the rest of the code working, but I get an error 1101 / argument value is not valid with this statement.

    The MS Project code that works when run in Project is this: 

                Application.MapEdit name:="visio_HLS_export", Create:=True, OverwriteExisting:=True, _
                DataCategory:=pjMapTasks, CategoryEnabled:=True, TableName:="tasks", _
                FieldName:="Unique ID", ExternalFieldName:="TaskUID", ExportFilter:="IsMilestoneFlag"

    The code in Visio is the same, except the "Application" object is replaced with my MSProject object (mspApp). I've got a similar routine set up to create the "IsMilestoneFlag" filter, and that is working fine. The filter is created in the local organizer, then copied to Global.mpt, so it should be able to find it. Not sure what else could be causing the failure. 

    Set mspApp = CreateObject("MSProject.Application") 

            mspApp.MapEdit Name:="visio_HLS_export", Create:=True, OverwriteExisting:=True, _
            DataCategory:=pjMapTasks, CategoryEnabled:=True, TableName:="tasks", _
            FieldName:="Unique ID", ExternalFieldName:="TaskUID", ExportFilter:="IsMilestoneFlag"

    Any ideas? 

    Friday, February 6, 2015 10:40 PM

Answers

  • matttjo,

    This might be s shot in the dark, but looking at the MapEdit Method, the only argument that is suspect when controlling Project from another app is the DataCategory argument. All other arguments are either string, or boolean. You might try adding a reference to the DataCategory, something like:

    DataCategory:=mspApp.pjMapTask

    Since all arguments of the method are optional, you could try eliminating one at a time (or adding one at a time) and see which one causes the problem.

    Hope this helps.

    John

    • Marked as answer by mattjo Tuesday, February 10, 2015 8:32 PM
    Saturday, February 7, 2015 4:44 PM

All replies

  • matttjo,

    This might be s shot in the dark, but looking at the MapEdit Method, the only argument that is suspect when controlling Project from another app is the DataCategory argument. All other arguments are either string, or boolean. You might try adding a reference to the DataCategory, something like:

    DataCategory:=mspApp.pjMapTask

    Since all arguments of the method are optional, you could try eliminating one at a time (or adding one at a time) and see which one causes the problem.

    Hope this helps.

    John

    • Marked as answer by mattjo Tuesday, February 10, 2015 8:32 PM
    Saturday, February 7, 2015 4:44 PM
  • John, thanks for the feedback! The DataCategory argument was indeed the culprit. Reviewing the documentation, I tried using the numerical value (0) instead of the pjMapTasks and it took the value and works great now. 

    --Matt

    Tuesday, February 10, 2015 7:28 PM
  • Matt,

    You're welcome and thanks for the feedback.

    If my help was useful, please consider marking my response as the answer or give it a vote

    John

    Tuesday, February 10, 2015 8:07 PM