Question

I have around 50 word documents in an old format which I need to convert to a new format. I was thinking of having a new format template and copying needed numbered fields from the old format into the new format using a macro, and finally saving this new document.

I have numbered fields from 1 to 6 in the old format where some fields are in the header. I need these fields in the new format where the sequence is different.

I am a absolute beginner in macros and need to submit this tomorrow so would appreciate any help or advise urgently.

Word documents download links are mentioned below:

OLD FORMAT : http://www.scribd.com/R0cKyMan/d/90470134-Old-Format

NEW FORMAT : http://www.scribd.com/R0cKyMan/d/90473107-New-Format

Was it helpful?

Solution

So can u help me out with copy header fields. Thanks – R0cKy 3 mins ago


The tables in the Header have to be accessed in a different way.

When a table is in the body, you can use it like this

ActiveDocument.Tables(1).Cell(1, 1).Select
Selection.Copy

But to access the table which is in the Header you have to access the Section in which the Header is. In your case the table is in wdHeaderFooterPrimary

Try this

Option Explicit

Sub Sample()
    '~~> Copies the 2nd Cell in the first row of a table which is in the Header
    ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Tables(1).Cell(1, 2).Select
    Selection.Copy

    '~~> Pastes it in say 1st cell in Row 1 of a table which is in the body
    ActiveDocument.Tables(1).Cell(2, 3).Select
    Selection.PasteAndFormat (wdPasteDefault)
End Sub

Hope this gets you started.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top