![]() |
#1
|
|||
|
|||
![]()
I'm running MSOffice 365 Home edition.
I have 1000's of Word document where I want to insert a Footer showing FILENAME and PAGE of NUMPAGES. I plan to do this 0) Add the footer with the needed FIELDS to the template 1) Run ONCE a treverse the hieraki of folders with the files 2) check if Footer exists already in each file If NOT then insert the FIELDS, UPDATE the fields SAVE the document again else leave the file be and treverse to next I have the new Footer inserted in the template and the treversing to function ! But the ONE-time-use subrutine to open a document and check for existing Footer is BAD ! I use this code for handlin a file from the hieraki: Code:
Sub insertFooterIfMissing(file As String) Dim appWrd As New Word.Application Dim doc As Word.Document Dim footer As HeaderFooter ' Set appWrd = CreateObject(Word.Application) ' Open the Word document Set doc = appWrd.Documents.Open(file) <<<<<<<< (A) ' Check if theapppWrd footer exists If doc.Sections(1).Footers(wdHeaderFooterPrimary).Exists Then <<<<<< (B) ' just leave it be Else ' insert the Footer here AND update the Footer Debug.Print "Nu indsættes Footer i : " & file End If ' Close the document doc.Close Set doc = Nothing Set appWrd = Nothing End Sub (A) this line is failing showing "macros is not allowed" in a Msgbox (B) is ALWAYS true eventhough the document has NO Footer ... not that I can see at least ! What do I do wrong ? |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
=CALLOUTTARGETREF()!Prop doesn't exist | BenMcLean | Visio | 9 | 07-13-2020 04:00 PM |
![]() |
Ken Leidner | Word VBA | 2 | 07-13-2018 12:34 PM |
Inserting unicode characters that don't exist in MS Word | jdavid10 | Word | 5 | 01-11-2017 12:14 PM |
Detecting that previous character doesn't exist (i.e., present character is first in document) | Robert K S | Word VBA | 15 | 08-01-2016 09:33 AM |
INCLUDETEXT is file doesn't exist | neoported | Mail Merge | 2 | 07-21-2016 11:47 PM |