Scan a directory, generate a dynamic form, and take user import, to build master document?

StackOverflow https://stackoverflow.com/questions/18083671

  •  23-06-2022
  •  | 
  •  

سؤال

Before staring down a long road leading to a dead end--and especially so since I have to dust off Perl programming skills, then learn VBA--is the following scenario feasible?

Using Word 2010 VBA:

  1. Open a starting .docm file (potentially a master document)
  2. Display a form
  3. Require user to enter data: project name, date, etc.
  4. Scan the starting file's directory
  5. Collect document properties: title, subject, total pages
  6. Create a dynamic list from all document properties.
  7. Insert list into form.
  8. Allow user to select required documents (e.g. checkboxes)
  9. Add selected documents to end of starting file.
  10. Update inserted documents with user data: project name, date, etc. (above)
  11. Generate table of contents at beginning of starting file.
  12. Prompt user to save file.
هل كانت مفيدة؟

المحلول

This is all feasible from Word VBA. From the description I wouldn't use Access, unless you need to store a large amount of data (or structured data) permanently - your description doesn't indicate this. Even then, if the data is just a simple (1D) table, I would prefer Excel to store it.

I wouldn't touch the Master Documents feature (if that is what you are referring to):

A master document has only two possible states: Corrupt, or just about to be corrupt. And that is why we say that the only possible fix to a master document is “don't use it!”

Why Master Documents Corrupt (MVP)

That page links to a further page here that describes how Master Documents might be used safely.

Besides which, your outline suggests that you are already creating your own version of a Master Document.

Hint: Rather than attempting to insert the document content as a file I would consider inserting a Section Break and then exploring the variety of Paste (and PasteSpecial) methods. Hans has some very useful code here.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top