0

I have a program which outputs a collection of tables in a word document which I eventually want to post as an html file with bookmarks and an index. The tables are grouped by "Name:" where there is a 3 row table that contains detailed header information for a section of data, then there is a second table which can span multiple pages which contains the data for that section. There is then a page break so that the next sections header table is on a new page. This can occur for a variable number of sections numbers in the hundreds. I need to write a script that

  1. searches my document for "Name:", which is unique and would not appear anywhere but the header table,
  2. grabs the text that follows "Name:" within that table cell (for example "Name: Line 1234)
  3. replaces all the blanks in that text string with an underscore to make it a suitable bookmark name,
  4. creates a bookmark with the name,
  5. goes back and creates an index at the front of the document
  6. Saves the file as an html

I have a passing familiarity with VB for word, I have used it a bit in excel, but am by no means an expert. I would appreciate any advice on functions and objects that I should be using for this script.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
MikeV
  • 1

1 Answers1

0

Hey MikeV from what I can gather, your problem seems more conceptual, less specific. What I mean is, have you started yet? Or looking at a blank script page?

I'm relatively new to coding, so I get that myself. What I do is make a list of what I need to do (what you have). Then think of the code or psuedo-code that would go with each step. Then you can start to build your script. You don't have to start with step one (as step 2/3 is often the more interesting bit), but let's do that.

Now, you need to search for a text string containing "Name:". I am proficient with VBA in excel, but haven't done anything for word. So I'd look it up. Googling "VBA find word in word document" will bring you to this page, which shows you how to approach step one. So steal their code, alter it to fit your needs and move on to step 2. Repeat the process, and that's how you build your algorithm! :)

Just a FYI, typically StackOverflow is for specific questions with an answer that can be confirmed, whereas you asked for help building an algorithm. I'd reserve those questions for your programming professor or friend who can help.

cheers

Community
  • 1
  • 1
Matthew
  • 672
  • 4
  • 11