none
Runtime Error 1101 When Using Macro to Distribute Customisations

    Frage

  • Hi,

    Project 2016 Professional, Windows 10.When running the following macro I am receiving the 1101 error:

    Sub DistributeTest()

    OrganizerMoveItem Type:=10, FileName:="Global.MPT", ToFileName:=ActiveProject.Name, Name:="NameOfTheItem"

    End Sub

    This is similar to this problem

    https://social.technet.microsoft.com/Forums/en-US/61c114e3-ef33-4040-8477-84c542a167eb/open-file-name-macro

    but my code does not contain the (same) errors.


    Mittwoch, 16. Mai 2018 14:16

Antworten

  • I have macros that use OrganizerMoveItem and they use a hard-coded filename without a path. However, I'm moving in the opposite direction, from my file into the Global. If a path is required to make it work, use ActiveProject.FullName. You may have to assign it to a string variable first.
    • Als Antwort markiert MorphaToo Freitag, 25. Mai 2018 15:13
    Mittwoch, 16. Mai 2018 17:09

Alle Antworten

  • Whats Going Ahn,

    I just did a quick test and the issue has to do with the ToFileName argument. It only works if I use the full path. For example, my active file is "Sub A" so

    OrganizerMoveItem Type:=10, FileName:="Global.MPT", ToFileName:=ActiveProject.Name, Name:="NameOfTheItem"

    does not work. However,

    OrganizerMoveItem Type:=10, FileName:="Global.MPT", ToFileName:="C:\Users\John\Documents\Sub A.mpp" Name:="NameOfTheItem"

    does work.

    Hope this helps.

    John

    Mittwoch, 16. Mai 2018 15:03
  • Thanks John. It's a useful workaround, but I need to distribute to a number of different files. That's why I am using the "ActiveProject.Name" approach.

    I need to loop through the files and apply the customisations to each one. I didn't include the loop as I'd already made sure it wasn't the issue.

    Mittwoch, 16. Mai 2018 15:36
  • Whats Going Ahn,

    It's not a workaround, its simply the way the Method works. Sometimes VBA syntax can be fussy so you have to go with what works. So loop through the files, find the path and make the Organizer move.

    John

    Mittwoch, 16. Mai 2018 15:47
  • It's the workaround I'm currently using because of this problem, as it works but it's likely that it will quickly become unmanageable for me in my current situation.

    I need to abstract away from specific filenames and, TMK, "ActiveProject.Name" is the way to do that. I need to be able to easily add and delete project files so I need to be flexible. I started using the same code some years ago....it has always worked fine.

    https://social.msdn.microsoft.com/Forums/en-US/c3b30d2d-19c1-4f76-a149-337850f54a5d/automate-distribution-of-custom-fields-to-other-to-live-project-files?forum=project2010custprog#bde3db3b-536f-4270-8ee4-0533150e682f

    In detail the code accesses each project via a hyperlink. When the project is open the customisations are assigned. The file is saved and closed, on to the next

    I know it isn't the code to open and close the projects that is causing the problem, which is why I didn't add it to the OP.

    Mittwoch, 16. Mai 2018 16:43
  • I have macros that use OrganizerMoveItem and they use a hard-coded filename without a path. However, I'm moving in the opposite direction, from my file into the Global. If a path is required to make it work, use ActiveProject.FullName. You may have to assign it to a string variable first.
    • Als Antwort markiert MorphaToo Freitag, 25. Mai 2018 15:13
    Mittwoch, 16. Mai 2018 17:09
  • Brilliant. ActiveProject.FullName does the job. Thanks.
    • Als Antwort markiert MorphaToo Freitag, 25. Mai 2018 12:26
    • Tag als Antwort aufgehoben MorphaToo Freitag, 25. Mai 2018 15:13
    Freitag, 25. Mai 2018 12:26