2016-07-18 29 views
-1

Ich habe ein Makro, das die Fußzeile von einem Word-Dokument zu einem anderen kopiert - das funktioniert perfekt, aber es hält nicht die Positionierung genau gleich - Ich brauche eine Fußzeile, um die gleiche Position zu sein zum mm. Kann mir jemand bei Änderungen des unten stehenden Codes helfen, damit dies geschieht?Kopiere eine Fußzeile mit Bild in ein anderes Word-Dokument

Sub UpdateDocuments() 
    Application.ScreenUpdating = False 
    Dim strFolder As String, strFile As String, strDocNm As String 
    Dim wdDocSrc As Document, wdDocTgt As Document, HdFt As HeaderFooter 
    Dim aStory As Range 
    Dim aField As Field 
    Dim oldFilename As String 
    Dim bmRange As Range 
    Dim Response As Integer 
    Dim i As Long 
    Dim l As Integer 

THEN der eigentliche Code der Fußzeile zu ersetzen

or Each HdFt In .Sections.First.Footers 
    If HdFt.Exists Then 
     If wdDocSrc.Sections.First.Footers(HdFt.Index).Exists Then 
     HdFt.Range.FormattedText = wdDocSrc.Sections.First.Footers(HdFt.Index).Range.FormattedText 

       'FILE NAME CODE 
       'Check if the DocName bookmark exists 
       If wdDocTgt.Bookmarks.Exists("DocName") = True Then 
       'If DocName bookmark does exist do this 
       Set bmRange = wdDocTgt.Bookmarks("DocName").Range 
         'NEW gets the name of the target document and removed the .doc extension 
         oldFilename = wdDocTgt.Name 
         If Right(oldFilename, 5) = ".docx" Then 
         oldFilename = Left(oldFilename, Len(oldFilename) - 5) 
          ElseIf Right(oldFilename, 4) = ".doc" Then 
          oldFilename = Left(oldFilename, Len(oldFilename) - 4) 

       'Update bmRange (DocName bookmark) with the file name with no extension 
       bmRange.Text = oldFilename 
         End If 
       End If 

       If wdDocTgt.Bookmarks.Exists("DocName2") = True Then 
       'If DocName bookmark does exist do this 

       Set bmRange = wdDocTgt.Bookmarks("DocName2").Range 
       'set bmRange as blank so as to no duplicate the name 
       bmRange.Text = " " 
        'NEW gets the name of the target document and removed the .doc extension 
         oldFilename = "" 
         oldFilename = wdDocTgt.Name 
         If Right(oldFilename, 5) = ".docx" Then 
         oldFilename = Left(oldFilename, Len(oldFilename) - 5) 
          ElseIf Right(oldFilename, 4) = ".doc" Then 
          oldFilename = Left(oldFilename, Len(oldFilename) - 4) 

       'Update bmRange (DocName bookmark) with the file name with no extension 
       bmRange.Text = oldFilename 
       End If 
      End If 
      'END FILE NAME CODE 

     End If 
    End If 

Antwort

0

(das auch den Namen des Dokuments in der Fußzeile hinzufügt) fand ich die folgende löste das Problem:

wdDocTgt.PageSetup.FooterDistance = wdDocSrc.PageSetup.FooterDistance