Topic
  • 3 replies
  • Latest Post - ‏2013-08-30T21:33:05Z by CJane
CJane
CJane
59 Posts

Pinned topic Can RPE process the Word FileName field? Does RPE know what the file name is?

‏2013-08-27T15:24:24Z |

I need to include the document filename in the header on the title page.

I've inserted a Field box from the RPE template palette in the right location, and in Properties > Formatting > specific > field type I've put Filename and in Properties > Formatting > specific > field code I've put FILENAME \* Lower \* MERGEFORMAT.

The filename is supposed to appear in parantheses, so on either side of the field box I've got a text box that contains a left and right parenthesis. The parentheses appear in the output, but there's nothing between them that suggests the presence of the field.

I might have the code wrong . . . or something else wrong . . . but I also wonder if RPE knows what the filename is when it's querying for the field? Is RPE able to make any connection between the filename field and the filename that appears in the RPE specification's target path for the RPE output?

I have a post-RPE macro that updates the fields in the document twice; the second time is to catch the correct number of total pages, which might have changed after the first update. I'm thinking that if the field is in place in the output, it would be updated during this second update.

I'll appreciate any comments or suggestions on this topic.

Updated on 2013-08-27T15:24:40Z at 2013-08-27T15:24:40Z by CJane
  • ChrisHardy68
    ChrisHardy68
    86 Posts

    Re: Can RPE process the Word FileName field? Does RPE know what the file name is?

    ‏2013-08-29T23:16:22Z  

    Hi,

    Here are a couple of thoughts that may wont solve the issue but may help:

    1. That field code should work so report it as a issue to Rational

    2. The RPE macro does not update the headers and footers consitantly so i added the following to the macro to try and force it:

    Sub UpdateOtherFields()
    ' UpdateFields Macro updates all fields in the active document

    Dim oStoryRange As Range
    Dim oField As Field

        For Each oStoryRange In ActiveDocument.StoryRanges
            For Each oField In oStoryRange.Fields
                oField.Update
            Next oField
        Next oStoryRange
        Set oStoryRange = Nothing
        Set oField = Nothing
    End Sub
    Sub UpdateFieldsAndSave()
    On Error Resume Next
    Err.Clear
        If Not ActiveDocument.Saved Then
            ActiveDocument.Save
                If Err.Number = 0 Then
                    On Error GoTo 0
                    UpdateOtherFields
                    ActiveDocument.PrintPreview
                    ActiveDocument.ClosePrintPreview
                    ActiveDocument.Save
                End If
        End If
    End Sub

    ' A macro to run them all
    Public Sub rpe()
        On Error Resume Next
        peInsertOLEs
        peUpdateFields
        peUpdateTablesOfFigures
        peUpdateTOCs
        
        UpdateFieldsAndSave
        
        ActiveDocument.Save
    End Sub
     

    3. Note: Following only applies to a .dsx file

    RPE does not seem to know what the file name is (the value set in the Runtime - Output - Target Word - Path attribute.

    So construct the file name and path you want in the an external variable, use that in the doc.

    Now to keep it consistant with the actual file name use something like the following in the attribute Runtime - metadata - Post command

    cmd /c copy "${Word}" "${Doc_Path}\${Doc_Name}.doc"

    Where

                Doc_Path is an external variable that contains the path where you what the file copied to

                Doc_Name is an external variable that contains the actual file name

    This command simply makes a copy of the file created by RPE to a new loacation with a new file name

    Sadly you cant use external variables in the Runtime - Output - Target Word - Path attribute

    Hope that helps

  • CJane
    CJane
    59 Posts

    Re: Can RPE process the Word FileName field? Does RPE know what the file name is?

    ‏2013-08-30T21:24:23Z  

    Hi,

    Here are a couple of thoughts that may wont solve the issue but may help:

    1. That field code should work so report it as a issue to Rational

    2. The RPE macro does not update the headers and footers consitantly so i added the following to the macro to try and force it:

    Sub UpdateOtherFields()
    ' UpdateFields Macro updates all fields in the active document

    Dim oStoryRange As Range
    Dim oField As Field

        For Each oStoryRange In ActiveDocument.StoryRanges
            For Each oField In oStoryRange.Fields
                oField.Update
            Next oField
        Next oStoryRange
        Set oStoryRange = Nothing
        Set oField = Nothing
    End Sub
    Sub UpdateFieldsAndSave()
    On Error Resume Next
    Err.Clear
        If Not ActiveDocument.Saved Then
            ActiveDocument.Save
                If Err.Number = 0 Then
                    On Error GoTo 0
                    UpdateOtherFields
                    ActiveDocument.PrintPreview
                    ActiveDocument.ClosePrintPreview
                    ActiveDocument.Save
                End If
        End If
    End Sub

    ' A macro to run them all
    Public Sub rpe()
        On Error Resume Next
        peInsertOLEs
        peUpdateFields
        peUpdateTablesOfFigures
        peUpdateTOCs
        
        UpdateFieldsAndSave
        
        ActiveDocument.Save
    End Sub
     

    3. Note: Following only applies to a .dsx file

    RPE does not seem to know what the file name is (the value set in the Runtime - Output - Target Word - Path attribute.

    So construct the file name and path you want in the an external variable, use that in the doc.

    Now to keep it consistant with the actual file name use something like the following in the attribute Runtime - metadata - Post command

    cmd /c copy "${Word}" "${Doc_Path}\${Doc_Name}.doc"

    Where

                Doc_Path is an external variable that contains the path where you what the file copied to

                Doc_Name is an external variable that contains the actual file name

    This command simply makes a copy of the file created by RPE to a new loacation with a new file name

    Sadly you cant use external variables in the Runtime - Output - Target Word - Path attribute

    Hope that helps

    This does help. Thank you very much.

    The easiest solution is to make the file name an attribute in the DOORS module, which can then be pulled into the header as a variable. I'll check again w/ my customer and see if this is a possibility. I'm thinking that the file name would be constant for each significant document revision, so it shouldn't be the case that the attribute has to be changed all that often.

  • CJane
    CJane
    59 Posts

    Re: Can RPE process the Word FileName field? Does RPE know what the file name is?

    ‏2013-08-30T21:33:05Z  
    • CJane
    • ‏2013-08-30T21:24:23Z

    This does help. Thank you very much.

    The easiest solution is to make the file name an attribute in the DOORS module, which can then be pulled into the header as a variable. I'll check again w/ my customer and see if this is a possibility. I'm thinking that the file name would be constant for each significant document revision, so it shouldn't be the case that the attribute has to be changed all that often.

    Okay, a miracle has occurred. An RPE miracle, which is really a miracle! I had surrendered on the filename issue and was working on my Rubik's cube of a table (a previous post). When I ran the output to check the table configuration, the filename appeared, too! I did the classic cartoon double-take! I couldn't believe it. Apparently it cured itself.