none
Help with Syntax RRS feed

  • Question

  • Hi All

    I need some help with Syntax please.  My current Syntax row I am having issues with is below for information and uder that is what I want to use to extract data from MS Project to MS Excel:

    xlSheet.Cells(i, 8).Value = t.Baseline & LastBaseline & "Finish"

    For example the variable "LastBaseline" would contain "10" and everything after the = sign should show t.Baseline10Finish.

    Any help appreciated.

    Kind regards

    Tony


    TKHussar

    Thursday, October 13, 2016 1:54 PM

Answers

  • Tony,

    Yeah, after I wrote my response I realized what you wanted to do.

    There are a couple of ways to do what you want. One is to use a Select Case statement with each value of your LastBaseline variable being a separate case. It's straightforward but it does take several lines of code.

    A little more sophisticated approach is to use a combination of the GetField and the FieldNameToFieldConstant Methods. For example, if you want the Baseline3Finish field, use

    t.getfield(fieldnametofieldconstant([your field],pjTask))

    where your field is the string expression, "Baseline" & LastBaseline & "Finish"

    Hope this helps.

    John

    • Marked as answer by TKHussar Monday, October 31, 2016 8:41 PM
    Thursday, October 13, 2016 6:12 PM

All replies

  • Tony,

    So why not just use t.Baseline10Finish?

    John

    Thursday, October 13, 2016 2:31 PM
  • Hi John

    Apologies, I should have made it clearer in the description of my problem.  We use Baselines 1 to 10 and create a weekly baseline to measure weekly slippage.  On that basis I want to use the last Baseline Created which could be anywhere from 1 to 10 to measure the slippage for that week.  So firstly I find out the last Baseline used and store that value in LastBaseline variable and I want to use the value in that variable when I export the BaselinnennFinish to Excel.

    Hope that makes sense now :-).

    Kind regards

    Tony


    TKHussar



    • Edited by TKHussar Thursday, October 13, 2016 2:53 PM
    Thursday, October 13, 2016 2:39 PM
  • Tony,

    Yeah, after I wrote my response I realized what you wanted to do.

    There are a couple of ways to do what you want. One is to use a Select Case statement with each value of your LastBaseline variable being a separate case. It's straightforward but it does take several lines of code.

    A little more sophisticated approach is to use a combination of the GetField and the FieldNameToFieldConstant Methods. For example, if you want the Baseline3Finish field, use

    t.getfield(fieldnametofieldconstant([your field],pjTask))

    where your field is the string expression, "Baseline" & LastBaseline & "Finish"

    Hope this helps.

    John

    • Marked as answer by TKHussar Monday, October 31, 2016 8:41 PM
    Thursday, October 13, 2016 6:12 PM
  • Hi John

    Works perfectly. Many many thanks for your help.

    Kind regards

    Tony


    TKHussar

    Friday, October 14, 2016 8:48 AM
  • Tony,

    You're welcome and thanks for the feedback.

    John

    Friday, October 14, 2016 2:15 PM