locked
Pull Filename/Filepath when extracting to excel RRS feed

  • Question

  • Hey All,

     I have a macro that extracts data from my project into an excel file with just the Task UID, Resource Names, and a few other things and I use it to integrate with COBRA. 

    However I only helped with this macro I noticed that the user always has to change the file name of the Project .mpp file and has to re-enter in a filename each time. I was curious how I can have VBA just pull that information and add it to the saved name of the excel file. Here is how the macro starts

    Const FILEPATH As String = "" 'replace with your filepath'
        Const FILENAME As String = ""  'replace with your filename
    
    
    At the Bottom of the macro we have this:
    
    xlBook.SaveAs FILENAME:=FILEPATH & FILENAME, FileFormat:=xlCSV
    
    (Which is why the filepath and filename are required)

    How can I stop the need for user entry? And just have whatever activeproject running the Macro automatically insert its file-path and filename. 

    Thank you for any help!

    Wednesday, August 15, 2012 3:48 PM

Answers

  • Hi ,

    You practically gave the solution yourself

    filepath=activeproject.path

    filename=activeproject.name

    That's it.

    Greetings,

    • Marked as answer by Jake683 Thursday, August 16, 2012 1:41 PM
    Wednesday, August 15, 2012 7:00 PM

All replies

  • I feel like it may need to be a class module
    Wednesday, August 15, 2012 4:22 PM
  • Hi ,

    You practically gave the solution yourself

    filepath=activeproject.path

    filename=activeproject.name

    That's it.

    Greetings,

    • Marked as answer by Jake683 Thursday, August 16, 2012 1:41 PM
    Wednesday, August 15, 2012 7:00 PM
  • So do I have to remove the constant at the top? I tried using that same line before but it doesn't seem to ever accept it.

    EDIT: Never mind I figured it out, thank you for your help Jan.

    • Edited by Jake683 Thursday, August 16, 2012 1:42 PM
    Thursday, August 16, 2012 1:35 PM