WORD macro unlink all fields. Problem with page numbers

Diskutiere und helfe bei WORD macro unlink all fields. Problem with page numbers im Bereich Microsoft Office im Windows Info bei einer Lösung; Hi I want to unlink all fields in a word document with a macro. It works with the following VBA code. But when I have page numbers multiple pages in... Dieses Thema im Forum "Microsoft Office" wurde erstellt von Robin Huber, 1. Dezember 2020.

  1. WORD macro unlink all fields. Problem with page numbers


    Hi

    I want to unlink all fields in a word document with a macro. It works with the following VBA code.

    But when I have page numbers multiple pages in a document the numbers will just show "1" on every site. Does someone have a workaround for this problem?

    Unlink all fields except the page numbers??



    Thankful for the help!


    Code:

    To unlink the fields in the body of the document I use this: ActiveDocument.Fields.Unlink

    To unlink header and footer I found this:


    Dim oField As Field
    Dim oSection As Section
    Dim oHeader As HeaderFooter
    Dim oFooter As HeaderFooter

    For Each oSection In ActiveDocument.Sections

    For Each oHeader In oSection.Headers
    If oHeader.Exists Then
    For Each oField In oHeader.Range.Fields
    oField.Unlink
    Next oField
    End If
    Next oHeader

    For Each oFooter In oSection.Footers
    If oFooter.Exists Then
    For Each oField In oFooter.Range.Fields
    oField.Unlink
    Next oField
    End If
    Next oFooter

    Next oSection
     
  2. Robin Huber Win User

    WORD macro unlink all fields. Problem with page numbers

    Dim oField As Field
    Dim oSection As Section
    Dim oHeader As HeaderFooter
    Dim oFooter As HeaderFooter

    For Each oSection In ActiveDocument.Sections

    For Each oHeader In oSection.Headers
    If oHeader.Exists Then
    For Each oField In oHeader.Range.Fields
    If oField.Type = wdFieldPage Then
    Else
    oField.Unlink
    End If
    Next oField
    End If
    Next oHeader

    For Each oFooter In oSection.Footers
    If oFooter.Exists Then
    For Each oField In oFooter.Range.Fields

    If oField.Type = wdFieldPage Then
    Else
    oField.Unlink
    End If
    Next oField
    End If
    Next oFooter

    Next oSection
  3. Lisa Wilke-Thissen Win User

    WORD macro unlink all fields. Problem with page numbers

    Hallo,

    dann wäre es doch nett, wenn du deine Lösung hier veröffentlichen würdest - für andere Hilfesuchende mit ähnlichem Problem.

    Viele Grüße

    Lisa
  4. Robin Huber Win User

    WORD macro unlink all fields. Problem with page numbers

    Hallo

    Vielen Dank für die Antwort. Ich habe jedoch jetzt das Makro so angepasst, dass alle Felder ausser der Seitenzahlen mit Unlink bearbeitet werden.

    LG
  5. Lisa Wilke-Thissen Win User

    WORD macro unlink all fields. Problem with page numbers

    Hallo,

    davon ausgehend, dass sich die Seitenzahlen in Kopf- (Header) oder Fußzeile (Footer) befinden, musst du Header und Footer im Makro ja nicht berücksichtigen.

    Oder befinden sich außer dem PAGE-Feld noch andere Felder in Header und Footer?

    Viele Grüße

    Lisa
  6. Robin Huber Win User

    Unlink Fields in Excel and PowerPoint

    Hello

    Thanks for the answers. But that's not what I'm looking for.

    I search for a solution to "unlink" the fields in header and footer. For example a date field, which updates when I print or open the file.

    In word I can do this with a macro, but in excel and powerpoint that solution didn't worked.
  7. User Advert


    Hi,

    willkommen im Windows Forum!
Thema:

WORD macro unlink all fields. Problem with page numbers - Microsoft Office

Die Seite wird geladen...

WORD macro unlink all fields. Problem with page numbers - Similar Threads - WORD macro unlink

Forum Datum

Problem with security phone numbe

Problem with security phone numbe: Hello,I have several Microsoft accounts, and have added my phone number to each. However, when logging in, I noticed I can only use it once. How do I secure the other accounts? I find this really...
Outlook.com 21. Juli 2021

MS Word macro

MS Word macro: Hi there, I would like to write a WORD macro that sends words to an API parallel to typing. Is that possible? A similar mechanism could possibly underly the MS Word spell checker. Is there any...
Microsoft Office 14. September 2020

WORD MACRO: Search for date fields and replace result

WORD MACRO: Search for date fields and replace result: Hi I'm working on a solution to search date fields in Word and replace the result. Replacing the result should be easy but how can I search for date fields?
Microsoft Office 9. September 2020

Excel - Unlink all header and footer fields by opening

Excel - Unlink all header and footer fields by opening: Hello I want to unlink the fields in the header and footer just like this example: https://stackoverflow.com/questions/42829402/vba-excel-unlink-headers-footers-in-word This example shows the...
Microsoft Office 23. Juni 2020

Unlink Fields in Excel and PowerPoint

Unlink Fields in Excel and PowerPoint: Hello How can I convert the fields dates, path... in powerpoint and excel to text? I know there's a chance to do this in word and it works fine. But how can I do it in powerpoint or excel? The...
Microsoft Office 16. Juni 2020

word vba custom page numbers

word vba custom page numbers: I would like to add a custom page numbering to my word doc, which would look like "1a, 2a, 3a, ..." or "5.1, 5.2, 5.3, ..." for example. Also it would be amazing, if this would show up in the...
Microsoft Office 15. Januar 2019

WORD 2016: since last update in Oct 2017, form fields referring to page numbers yield...

WORD 2016: since last update in Oct 2017, form fields referring to page numbers yield...: Since the last update in Oct 2017, form fields containing cross-references to page numbers are no longer correctly resolved in header and footer. They stay the same throughout the document,...
Microsoft Office 23. Oktober 2017
WORD macro unlink all fields. Problem with page numbers solved
  1. Diese Seite verwendet Cookies, um Inhalte zu personalisieren, diese deiner Erfahrung anzupassen und dich nach der Registrierung angemeldet zu halten.
    Auf dieser Website werden Cookies für die Zugriffsanalyse und Anzeigenmessung verwendet.
    Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies.