• Word 2010 Footer Macro ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Error

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Word 2010 Footer Macro ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Error

    Author
    Topic
    #502896

    I have a macro that inserts the filename into a footer. If I keep the macro code in the normal template, it works perfectly. However, if I put the code into a separate .DOTM file so that I can circulate it for others to use, I always get a debug error at ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument. Why? Does this command only work if run from normal.dotm? Although it may be too much, I’ve included my entire macro code below. The error occurs after the ReturnToDocEditing label. I create a bookmark called ReturnHere when the macro first runs. Then after the macro runs, I return to the document and return to bookmark ReturnHere. If I take out the SeekMainDoc code in a separate .DOTM, the macro runs but it leaves the footer editing window open, which I do not want. I thought SeekMainDoc would return me to the doc I was editing in my original normal view. Thoughts? Thanks!

    -Rich Belthoff

    Code:
    Sub eDocsFooterNew()
    ‘
    ‘ eDocs Filename Footer
    ‘ 2013-09-09; Corrected 2013-09-12; Modified 2015-10-29
    ‘
    ‘
    Dim vFileNameFull As String
    Dim vTrackChanges
    Dim vFileNamePartial As String
    Dim vNum As Integer
    Dim vWhiteSpace
    Dim vChar
    
    
        ‘Checks for Track Changes (resets Track Changes at end of macro)
        If ActiveDocument.TrackRevisions = True Then
            ActiveDocument.TrackRevisions = False
            vTrackChanges = 1
        Else
            vTrackChanges = 0
        End If
        
        ‘Checks for display of white space
        If ActiveWindow.View.DisplayPageBoundaries = True Then
            vWhiteSpace = 1
        Else
            vWhiteSpace = 0
        End If
    
    
        ‘Ensures that viewing doc in page view
        If ActiveWindow.View.SplitSpecial  wdPaneNone Then
            ActiveWindow.Panes(2).Close
        End If
        If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
            ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
             = wdMasterView Then
            ActiveWindow.ActivePane.View.Type = wdPageView
        End If
        
        ‘Set bookmark for return location after macro completes
        With ActiveDocument.Bookmarks
            .Add Range:=Selection.Range, Name:=”ReturnHere”
            .DefaultSorting = wdSortByName
            .ShowHidden = False
        End With
        
        ‘Moves to top of Doc, Inserts Hard Return & Sets Font
        Selection.HomeKey Unit:=wdStory
        Selection.TypeParagraph
        Selection.MoveUp Unit:=wdLine, Count:=1
        Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
        Selection.Style = ActiveDocument.Styles(“Normal”)
         
        ‘Inserts full eDocs filename
        Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
            “FILENAME  * Upper “, PreserveFormatting:=True
            ‘ Changed to upper 2013-10-18 so that sub-versions use upper case letters
        
        ‘Selects filename (from right to left) (modified 2013-10-18)
        Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
        Selection.Font.Name = “Arial”
        Selection.Font.Size = 8
        vFileNameFull = Selection.Text ‘Assigns filename to variable
        Selection.TypeText Text:=vFileNameFull ‘Inserts filename as plain text
        Selection.HomeKey Unit:=wdLine ‘Move IP to beginning of line
        Selection.Delete Unit:=wdCharacter, Count:=6 ‘Deletes “edocs ”
        Selection.TypeText Text:=”eDocs ” ‘Inserts “eDocs ” instead
        Selection.MoveLeft Unit:=wdWord, Count:=1 ‘Moves cursor before eDocs
        Selection.MoveRight Unit:=wdCharacter, Count:=5, Extend:=wdExtend ‘Selects eDocs
        Selection.NoProofing = True ‘Turns off spellcheck for eDocs (won’t save in custom .DIC as eDocs)
        Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘Moves cursor right to turn off selection
            
        If Selection.Type = wdSelectionIP Then ‘Selects text to next hyphen (hyphen before version)
                vFileNamePartial = Selection.MoveEndUntil(Cset:=”-“)
                Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘ Moves IP to right (just before hyphen)
        End If
        
        Selection.Delete Unit:=wdCharacter, Count:=1 ‘ Deletes hypen before “v” (version)
        Selection.TypeText Text:=”v”    ‘Enters a lower case “v” Modified 2013-10-18
        Selection.Delete Unit:=wdCharacter, Count:=1 ‘ Deletes the upper case “V”
        
        If Selection.Type = wdSelectionIP Then ‘ Selects text to hyphen after version)
                vFileNamePartial = Selection.MoveEndUntil(Cset:=”-“)
                Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘ Moves IP to last hyphen before filename
        End If
           
        If Selection.Type = wdSelectionIP Then ‘Selects text to right of IP & up to Tab
            vChar = Selection.MoveEndUntil(Cset:=vbCr, Count:=100) ‘ Extend selection to Tab
        End If
        
        Selection.Delete Unit:=wdCharacter, Count:=1 ‘ Deletes the remainder of the filename
    
    
        ‘Selects remaining filename, adds Bookmark, deletes filename & blank line at top of doc
        Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
        vFileNamePartial = Selection.Text ‘Assigns filename to variable
        Selection.Cut
        Selection.Delete Unit:=wdCharacter, Count:=1
        
        If ActiveDocument.Bookmarks.Exists(“eDocsName”) Then
            ActiveDocument.Bookmarks(“eDocsName”).Select
            Selection.Delete Unit:=wdCharacter, Count:=1
            Selection.InsertAfter vFileNamePartial
            ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:=”eDocsName”
            Selection.Font.Name = “Arial”
            Selection.Font.Size = 8
            GoTo ReturnToDocEditing
        Else
            GoTo NoBookmark
        End If
         
    NoBookmark:
    
    
    ‘   Need to determine what to do if there is no tab, which messes up some docs.
    ‘   Also, could use called functions because inserting the filename
    ‘   is the same code.
    
    
        ‘Moves insertion point to footer
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
        If Selection.HeaderFooter.IsHeader = True Then
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
        Else
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
        End If
        
        ‘Selects text to first tab (including the WF date stamp if it exists)
        If Selection.Type = wdSelectionIP Then ‘Selects text to right of IP & up to Tab
            vChar = Selection.MoveEndUntil(Cset:=vbTab, Count:=100) ‘ Modified 2013-10-03; extend selection to Tab
            ‘Selection.MoveEndWhile Cset:=”abcdefghijklmnopqrstuvwxyWBFD0123456789~`!@#$%^&*()-_+{}|[];:,./? “, Count:=wdForward
        End If
        
        ‘Deletes the selected text
        Selection.TypeBackspace
        
        Selection.PasteAndFormat (wdFormatOriginalFormatting)   ‘Pastes short filename
        Selection.HomeKey Unit:=wdLine, Extend:=wdExtend    ‘Selects filename
        With ActiveDocument.Bookmarks                       ‘Assigns bookmark name
            .Add Range:=Selection.Range, Name:=”eDocsName”
            .DefaultSorting = wdSortByName
            .ShowHidden = False
        End With
        
    ReturnToDocEditing:
    
    
        ‘Returns insertion point to main doc
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument   [COLOR=#ff0000]’PROBLEM OCCURS HERE![/COLOR]
        
        ‘Returns insertion point to last edited location bookmark
        Selection.GoTo What:=wdGoToBookmark, Name:=”ReturnHere”
        ActiveDocument.Bookmarks(“ReturnHere”).Delete
        With ActiveDocument.Bookmarks
            .DefaultSorting = wdSortByName
            .ShowHidden = False
        End With
        
        ‘Turns track changes back on if applicable
        If vTrackChanges = 1 Then
            ActiveDocument.TrackRevisions = True
        Else
            ActiveDocument.TrackRevisions = False
        End If
        
        ‘Turns white space display on or off as applicable
        If vWhiteSpace = 1 Then
            ActiveWindow.View.DisplayPageBoundaries = True
        Else
            ActiveWindow.View.DisplayPageBoundaries = False
        End If
    End Sub
    
    Viewing 3 reply threads
    Author
    Replies
    • #1535115

      Thoughts?

      This is not a job for a macro. It may be a job for a template.
      See the footer samples here.

      It may also be a job for AutoText or a Building Block. Here are samples of these methods.

      Sorry, I have not analyzed your code because I feel like you are trying to reinvent the wheel.

      • #1535125

        Thoughts?

        This is not a job for a macro. It may be a job for a template.
        See the footer samples here.

        It may also be a job for AutoText or a Building Block. Here are samples of these methods.

        Sorry, I have not analyzed your code because I feel like you are trying to reinvent the wheel.

        Thanks, but those options don’t get me where I want to be. We have a doc management system that generates a file name. It’s a long file name consisting of the doc number and other text. My macro strips out a lot of the file name and just leaves the number. I want to be able to hit a hotkey and have the file name added or updated in any document, whether we generate the doc or some third-party generates the doc. I don’t want to have to click in the footer and use AutoText or a Building Block. A template doesn’t really help because I get docs from other parties, re-save to my system, and add the file name. A template isn’t going to update the file name in the third-party document.

        I probably shouldn’t have included the entire code. My only issue is with the wdSeekMainDocument error. I just wanted to know how to get around that. However, as is often the case, after I posted the question I found a solution. My macro code enters the footer two different ways depending upon whether or not a bookmark already exists. For one way, my original code worked. For the other way, I had to close the footer editing window differently. The code now works. I am still tweaking another issue, though. Once I’m done I will probably post the code in case others find it useful.

        Thanks.

        -Rich

    • #1535167

      I’m glad you got it to work. Macros dealing with headers/footers are tricky because each Section of a document will have three headers and three footers (whether displayed or not). The total number of independent headers or footers depends on the link-to-previous setting (which can be different for each footer and each header in each section). A single page can have multiple sections. You will have to loop through the footers for each section.

      A suggestion would be to implant your number as a document variable or property and use a field to display it. That would make it far harder for the casual user to change it or even find it. That field could be in a building block or AutoText and your macro could insert that. I believe document properties can be accessed from outside a document.

      • #1535328

        I’m glad you got it to work. Macros dealing with headers/footers are tricky because each Section of a document will have three headers and three footers (whether displayed or not). The total number of independent headers or footers depends on the link-to-previous setting (which can be different for each footer and each header in each section). A single page can have multiple sections. You will have to loop through the footers for each section.

        A suggestion would be to implant your number as a document variable or property and use a field to display it. That would make it far harder for the casual user to change it or even find it. That field could be in a building block or AutoText and your macro could insert that. I believe document properties can be accessed from outside a document.

        I understand that there might be multiple footers. A macro still seems the easiest way to go. This is mostly used by me and I’m sophisticated enough to know what to do if it doesn’t work correctly (I just ran across a bug in my code this morning because the macro couldn’t handle a really LONG filename). I would use a field if the field didn’t include the full filename. All I want is the file number applied to the file in the system. I can’t parse that out of a field. Is there a way to only get part of the filename in a field? Thanks.

    • #1535168

      There is no need to select anything, or to use SeekView or any of the associated code for moving about the document.

      If I’ve understood your code correctly, you could do the lot with:

      Code:
      Sub eDocsFooterNew()
      '
      ' eDocs Filename Footer
      '
      Application.ScreenUpdating = False
      Dim bTrkChng, strNm As String, Rng As Range
      With ActiveDocument
      
        'Checks for Track Changes (resets Track Changes at end of macro)
        bTrkChng = .TrackRevisions
        .TrackRevisions = False
          
        'Get required portion of filename
        strNm = Split(Replace(Replace(.Name, "edocs ", "eDocs "), "- version", "Version"), "-")(0)
          
        'Insert tracking name into footer on first page
        With .Sections.First
          If .Footers(wdHeaderFooterFirstPage).Exists Then
            Set Rng = .Footers(wdHeaderFooterFirstPage).Range
          Else
            Set Rng = .Footers(wdHeaderFooterPrimary).Range
          End If
          With Rng
            .End = .Start + InStr(.Text, vbTab) - 1
            .Text = strNm
            'Format the tracking name
            With .Font
              .Name = "Arial"
              .Size = 8
            End With
            .Words.First.NoProofing = True 'Turns off spellcheck for eDocs (won't save in custom .DIC as eDocs)
          End With
        End With
        
        'Bookmark the tracking name
        .Bookmarks.Add Range:=Rng, Name:="eDocsName"
          
        'Turns track changes back on if applicable
        .TrackRevisions = bTrkChng
      End With
      Set Rng = Nothing
      Application.ScreenUpdating = True
      End Sub

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1535327

        There is no need to select anything, or to use SeekView or any of the associated code for moving about the document.

        Wow. I will check this out. I figured there was a much shorter way to do what I am trying to do, but I am not an expert at Word macros so I just use what I know about and often what I can record.

        Thanks!

        -Rich B

      • #1535329

        I haven’t tried the other suggested code yet, but if anybody else wants my more complicated code, here it is. I just updated it again this morning because it wasn’t working with a REALLY long filename.

        Code:
        Sub eDocsFooterNewNorm()
        ‘
        ‘ eDocs Filename Footer
        ‘ 2013-09-09; Corrected 2013-09-12; Modified 2015-10-29; 2015-11-02
        ‘
        ‘
        Dim vFileNameFull As String
        Dim vTrackChanges
        Dim vFileNamePartial As String
        Dim vNum As Integer
        Dim vWhiteSpace
        Dim vChar
        Dim vBookMarkExists
        Dim vViewType
           
            ‘Checks for Track Changes (resets Track Changes at end of macro)
            If ActiveDocument.TrackRevisions = True Then
                ActiveDocument.TrackRevisions = False
                vTrackChanges = 1
            Else
                vTrackChanges = 0
            End If
            
            ‘Checks for display of white space
            If ActiveWindow.View.DisplayPageBoundaries = True Then
                vWhiteSpace = 1
            Else
                vWhiteSpace = 0
            End If
        
            ‘Set bookmark for return location after macro completes
            With ActiveDocument.Bookmarks
                .Add Range:=Selection.Range, Name:=”ReturnHere”
                .DefaultSorting = wdSortByName
                .ShowHidden = False
            End With
        
            ‘Ensures that viewing doc in page view (and saves current view)
            If ActiveWindow.View.SplitSpecial  wdPaneNone Then
                ActiveWindow.Panes(2).Close
            End If
            If ActiveWindow.ActivePane.View.Type = wdNormalView Then
                vViewType = “Normal”
            End If
            If ActiveWindow.ActivePane.View.Type = wdOutlineView Then
                vViewType = “Outline”
            End If
            If ActiveWindow.ActivePane.View.Type = wdMasterView Then
                vViewType = “Master”
            End If
            If ActiveWindow.ActivePane.View.Type = wdPageView Then
                vViewType = “Page”
            End If
            If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
                ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _
                 = wdMasterView Then
                ActiveWindow.ActivePane.View.Type = wdPageView
            End If
                
            ‘Moves to top of Doc, Inserts Hard Return & Sets Font
            Selection.HomeKey Unit:=wdStory
            Selection.TypeParagraph
            Selection.MoveUp Unit:=wdLine, Count:=1
            Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
            Selection.Style = ActiveDocument.Styles(“Normal”)
             
            ‘Inserts full eDocs filename
            Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
                “FILENAME  * Upper “, PreserveFormatting:=True
                ‘ Changed to upper 2013-10-18 so that sub-versions use upper case letters
            
            ‘Selects filename (from right to left) (modified 2013-10-18)
            Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
            Selection.Font.Name = “Arial”
            Selection.Font.Size = 8
            vFileNameFull = Selection.Text ‘Assigns filename to variable
            Selection.TypeText Text:=vFileNameFull ‘Inserts filename as plain text
        ‘    Selection.HomeKey Unit:=wdLine ‘Move IP to beginning of line
            Selection.HomeKey Unit:=wdStory ‘Move to top of doc for really long filename 2015-11-02
            Selection.Delete Unit:=wdCharacter, Count:=6 ‘Deletes “edocs ”
            Selection.TypeText Text:=”eDocs ” ‘Inserts “eDocs ” instead
            Selection.MoveLeft Unit:=wdWord, Count:=1 ‘Moves cursor before eDocs
            Selection.MoveRight Unit:=wdCharacter, Count:=5, Extend:=wdExtend ‘Selects eDocs
            Selection.NoProofing = True ‘Turns off spellcheck for eDocs (won’t save in custom .DIC as eDocs)
            Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘Moves cursor right to turn off selection
                
            If Selection.Type = wdSelectionIP Then ‘Selects text to next hyphen (hyphen before version)
                    vFileNamePartial = Selection.MoveEndUntil(Cset:=”-“)
                    Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘ Moves IP to right (just before hyphen)
            End If
            
            Selection.Delete Unit:=wdCharacter, Count:=1 ‘ Deletes hypen before “v” (version)
            Selection.TypeText Text:=”v”    ‘Enters a lower case “v” Modified 2013-10-18
            Selection.Delete Unit:=wdCharacter, Count:=1 ‘ Deletes the upper case “V”
            
            If Selection.Type = wdSelectionIP Then ‘ Selects text to hyphen after version)
                    vFileNamePartial = Selection.MoveEndUntil(Cset:=”-“)
                    Selection.MoveRight Unit:=wdCharacter, Count:=1 ‘ Moves IP to last hyphen before filename
            End If
               
            If Selection.Type = wdSelectionIP Then ‘Selects text to right of IP & up to CR
                vChar = Selection.MoveEndUntil(Cset:=vbCr, Count:=300) ‘ Extend selection to CR; Increased Count 2015-11-02
            End If
            
            Selection.Delete Unit:=wdCharacter, Count:=1 ‘ Deletes the remainder of the filename
        
            ‘Selects remaining filename, adds Bookmark, deletes filename & blank line at top of doc
            Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
            vFileNamePartial = Selection.Text ‘Assigns filename to variable
            Selection.Cut
            Selection.Delete Unit:=wdCharacter, Count:=1
            
            If ActiveDocument.Bookmarks.Exists(“eDocsName”) Then
                vBookMarkExists = 1
                ActiveDocument.Bookmarks(“eDocsName”).Select
                Selection.Delete Unit:=wdCharacter, Count:=1
                Selection.InsertAfter vFileNamePartial
                ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:=”eDocsName”
                Selection.Font.Name = “Arial”
                Selection.Font.Size = 8
                GoTo ReturnToDocEditing
            Else
                vBookMarkExists = 0
                GoTo NoBookmark
            End If
             
        NoBookmark:
        
        ‘   Need to determine what to do if there is no tab, which messes up some docs.
        ‘   Also, could use called functions because inserting the filename
        ‘   is the same code.
        
            ‘Moves insertion point to footer
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
            If Selection.HeaderFooter.IsHeader = True Then
                ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
            Else
                ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
            End If
            
            ‘Selects text to first tab (including the WF date stamp if it exists)
            If Selection.Type = wdSelectionIP Then ‘Selects text to right of IP & up to Tab
                vChar = Selection.MoveEndUntil(Cset:=vbTab, Count:=100) ‘ Modified 2013-10-03; extend selection to Tab
                ‘Selection.MoveEndWhile Cset:=”abcdefghijklmnopqrstuvwxyWBFD0123456789~`!@#$%^&*()-_+{}|[];:,./? “, Count:=wdForward
            End If
            
            ‘Deletes the selected text
            Selection.TypeBackspace
            
            Selection.PasteAndFormat (wdFormatOriginalFormatting)   ‘Pastes short filename
            Selection.HomeKey Unit:=wdLine, Extend:=wdExtend    ‘Selects filename
            With ActiveDocument.Bookmarks                       ‘Assigns bookmark name
                .Add Range:=Selection.Range, Name:=”eDocsName”
                .DefaultSorting = wdSortByName
                .ShowHidden = False
            End With
            
        ReturnToDocEditing:
        
            ‘Returns insertion point to main doc
            If vBookMarkExists = 1 Then
                ActiveWindow.ActivePane.Close   ‘Closes footer editing window
            Else
                ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
            End If
            
        ‘   Original PageView Code
        ‘    If ActiveWindow.View.SplitSpecial = wdPaneNone Then ‘Returns to PageView
        ‘        ActiveWindow.ActivePane.View.Type = wdPageView
        ‘    Else
        ‘        ActiveWindow.View.Type = wdPageView
        ‘    End If
            
            If ActiveWindow.View.SplitSpecial = wdPaneNone Then ‘Returns to PageView
        ‘        ActiveWindow.ActivePane.View.Type = wdPageView
                If vViewType = “Normal” Then
                    ActiveWindow.ActivePane.View.Type = wdNormalView
                End If
                If vViewType = “Outline” Then
                    ActiveWindow.ActivePane.View.Type = wdOutlineView
                End If
                If vViewType = “Master” Then
                    ActiveWindow.ActivePane.View.Type = wdMasterView
                End If
                If vViewType = “Page” Then
                    ActiveWindow.ActivePane.View.Type = wdPageView
                End If
                
            Else
                If vViewType = “Normal” Then
                    ActiveWindow.View.Type = wdNormalView
                End If
                If vViewType = “Outline” Then
                    ActiveWindow.View.Type = wdOutlineView
                End If
                If vViewType = “Master” Then
                    ActiveWindow.View.Type = wdMasterView
                End If
                If vViewType = “Page” Then
                    ActiveWindow.View.Type = wdPageView
                End If
            End If
            
            ‘Returns insertion point to last edited location bookmark
            Selection.GoTo What:=wdGoToBookmark, Name:=”ReturnHere”
            ActiveDocument.Bookmarks(“ReturnHere”).Delete
            With ActiveDocument.Bookmarks
                .DefaultSorting = wdSortByName
                .ShowHidden = False
            End With
            
            ‘Turns track changes back on if applicable
            If vTrackChanges = 1 Then
                ActiveDocument.TrackRevisions = True
            Else
                ActiveDocument.TrackRevisions = False
            End If
            
            ‘Turns white space display on or off as applicable
            If vWhiteSpace = 1 Then
                ActiveWindow.View.DisplayPageBoundaries = True
            Else
                ActiveWindow.View.DisplayPageBoundaries = False
            End If
               
        End Sub
      • #1535330

        There is no need to select anything, or to use SeekView or any of the associated code for moving about the document.

        I hate to bug you, but your code is so much more elegant than mine. However, the StrNm line doesn’t grab the correct filename. It just inserts EDOCS into the footer. Here is a sample filename:

        EDOCS-#6758166-v2A-Raleigh_NC_(1100_Corporate_Center_Drive)_(BE_141281-20000)_Tenant_Estoppel.docx

        I want to change EDOCS to eDocs, get rid of the first hyphen and make it a space, delete the second hyphen, and delete the third hyphen and everything else so that it looks like this:

        eDocs #6758166v2A

        Can this be done with Split?

        By the way, the version number is not always constant. It could be v1, v1A, v20A, v30C, etc. That probably doesn’t matter if you trigger the split by the hyphen, which is always there.

        Thanks!

        -Rich B

    • #1535395

      Instead of:
      strNm = Split(Replace(Replace(.Name, “edocs “, “eDocs “), “- version”, “Version”), “-“)(0)
      you could use:
      strNm = “eDocs ” & Split(.Name, “-“)(1) & Split(.Name, “-“)(2)

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #1535428

        Instead of:
        strNm = Split(Replace(Replace(.Name, “edocs “, “eDocs “), “- version”, “Version”), “-“)(0)
        you could use:
        strNm = “eDocs ” & Split(.Name, “-“)(1) & Split(.Name, “-“)(2)

        Works perfectly. Thanks!!

        -Rich B

    Viewing 3 reply threads
    Reply To: Word 2010 Footer Macro ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument Error

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: