none
VBA. Where can I save the settings entered by the user? RRS feed

  • Question

  • VBA. 

    Step 1
    The MS Project file is open.
    The user starts the macro.
    The form is opened.
    The user enters the path.
    The user clicks "Save".
    The user closes the form.
    The user closes the MS Project file.

    Step 2
    The user opens the MS Project file.
    The user wins the macro.
    The form is opened.
    The form displays the path that the user has registered for "Stage 1"

    Questions

    How to make that when the user opens the form a second time (Step 2) in the form was displayed the path that was saved in (Step 1)?
    In other words, after the form was closed (Step 1), the value of the textbox was retained?

    Can this textbox value be saved in the MS Project file?
    Or should I save it in a separate file?
    How is this best done?





    • Edited by prog1003 Thursday, February 22, 2018 6:30 PM
    Thursday, February 22, 2018 6:24 PM

All replies

  • The two links from Sam are for [apps and] Add-Ins.  For simple VBA, I see three key options:

    1. Save and retrieve them from an external text file using some standard text file manipulation functions like "Open for Input", "Line Input", "Open for Output", and "Print."

    2. Store them in the .mpp file using one or more added Custom Document Properties fields.

    3. Store them in the .mpp file using the available Custom fields of the Project Summary Task. E.g. "activeproject.ProjectSummaryTask.Text20."

    The last option is simplest.

     [Edited per Sam's later comment.  While perhaps not designed for them, My.Settings has worked quite well for my VSTO customizations, i.e. "add-ins."]


    • Proposed as answer by John - Project Thursday, February 22, 2018 11:35 PM
    • Edited by Tom BoyleBPC Friday, February 23, 2018 3:03 PM
    Thursday, February 22, 2018 11:15 PM
  • Okay, I apologize. Yes I was referring to VB.Net. I am sorry that I did not see this is for VBA. But I still say that "My.Settings" is not designed for add-ins.


    Sam Hobbs
    SimpleSamples.Info

    Thursday, February 22, 2018 11:52 PM
  • You could also add a CustomDocumentProperty to the project and save it there. This allows you to create an unlimited number of properties, in case you need more that just the ones provided in the ProjectSummaryTask text fields. Custom Document Properties are also neat in that you can view them without opening MSP by right-clicking on the project file in Explorer and selecting Properties.
    Monday, February 26, 2018 5:42 PM