HOW TO MODIFY WORD HEADER VIA VBA?

Updated on workplace 2024-05-05
11 answers
  1. Anonymous users2024-02-09

    In fact, through macro recording, you can completely understand, some problems can be easily solved by yourself, macro recording is a very important step in learning VBA, you have to try more:

    As follows. if <>wdpanenone thenend if

    if = wdnormalview or activewindow. _

    wdoutlineview then

    wdprintview

    end if

    wdseekcurrentpageheader"Blank").insert where:= _,richtext:=true

    text:="Dark, dark, dark"

  2. Anonymous users2024-02-08

    Modify as follows: sub deletes header footer ().

    dim myrange as range

    on error resume next

    for each osec in 'A loop in a section of a document.

    set myrange =

    Delete the content in the header.

    wdlinestylenone 'Paragraph lower border line.

    set myrange =

    Delete the content in the footer.

    nextend sub

  3. Anonymous users2024-02-07

    Dear, this sentence needs to be changed:

    replace(replace(, "abc", 111"), chr(13), because, if you look closely, you will see that the text in the header has a carriage return character at the end, just like the end of a paragraph or **, which is also part of the header. You can use len (look at the length of the header, which includes the carriage return character at the end (chr(13)). So, when you replace it with replace, the carriage return character is still there.

    Note: The key is that when assigning a value, Word VBA does not contain the last carriage return character by default; It's easier to program, otherwise you'll have to remember to add a chr (13) at the end every time, which will annoy you to death!

    Finally, the solution is to use replace again and remove the carriage return before assigning the value.

  4. Anonymous users2024-02-06

    sub abc()

    dim mysec as section

    dim myshape1 as shape, myshape2 as inlineshape

    Change the AAA in all headers to BBB, please replace the corresponding content by yourself, if you need to delete AAA, BBB is empty.

    for each mysec in

    replace(, "aaa", "bbb")next mysec

    Deletes all drawing objects in the document.

    for each myshape1 in

    next myshape1

    Deletes all embedded objects in the document.

    for each myshape2 in

    next myshape2

    Save the document without prompting.

    noprompt:=true

    end sub

  5. Anonymous users2024-02-05

    sub test()

    falsewithleftheader = "" 'The left of the header is set to: Empty.

    centerheader = "&f" 'The header is set to: file name.

    rightheader = "" 'The right of the header is set to: empty.

    leftfooter = "&b Confidential &b" 'The left of the footer is set to: bold Confidential.

    centerfooter = "&d" 'In the footer, it is set to: Current Date.

    rightfooter = "Page &p" 'The right of the footer is set to: page number.

    end with

    trueend sub

  6. Anonymous users2024-02-04

    sub setpagefont() = false with .leftheader = The left of the header is set to: null

    centerheader = f" 'In the header, set the blind hall as: file namerightheader = The right of the header is set to:

    Emptyleftfooter = b confidential &b" 'The left of the footer is set to: bold Confidential.

    centerfooter = d" 'The footer in the mausoleum is set to: Current Daterightfooter = Page &p" 'The footer grinding right is set to:

    Page end with = trueend sub

  7. Anonymous users2024-02-03

    This macro is to find and replace the selected text, if it is not selected, it cannot be replaced.

  8. Anonymous users2024-02-02

    Record macros. So-called macros are batch scripts. In fact, it is also a vb**.

  9. Anonymous users2024-02-01

    Why is it possible to replace page numbers in the conventional substitution method, but with vb** it just doesn't.

  10. Anonymous users2024-01-31

    You can do this, save Word as XML, and then use a VB script to manipulate this XML

  11. Anonymous users2024-01-30

    Is it the text in the footer?

Related questions
4 answers2024-05-05

1. If you want to set a separate header and footer for a certain page, you need to divide this page into separate sections. First, before positioning the cursor before the first character of the current page, switch to the "Page Layout" ribbon, click on the "Separator" drop-down menu, and select the "Section Break" - "Next Section" item. >>>More

3 answers2024-05-05

Each is its own and does not affect each other.

If you want to set different styles of headers and footers in the same article, you can break the link by inserting and inserting section breaks. The main setting method of word2003 is: ** There is a change in formatting, insert a separator on which page starts Next page (section break type), then start with the following sections, click "Link to Previous" (4th to last button) on the header and footer menu, and continue to click for page numbers. >>>More

7 answers2024-05-05

I think you can do this, first open a blank document, then open the header footer option, remove the horizontal line (first select the paragraph marker for this eyebrow line and click on the format-border and shading-border, check none, OK in the options under Settings), then save this blank document as a template file and take a name of your choice, and then"Documents and settings for your username Application Data Microsoft Templates"Select the Chinese file and delete it, then find the template file you just saved, change the name of the file to it, and save it to"Documents and settings for your username Application Data Microsoft Templates"path. >>>More

10 answers2024-05-05

<>2. Find the page layout-separator.

<>5. Delete all the Chinese characters in the header. >>>More

9 answers2024-05-05

The steps to remove a blank page with a page footer added in Word are as follows: >>>More