Macro to extract text from a cell in a table located in the document header

So I was able to modify this macro:

https://msdn.microsoft.com/en-us/library/aa537149(v=office.11).aspx#officewordautomatingtablesdata_extractingdatafromatable

So it worked to read the table in the header as follows:

Set doc = ActiveDocument
Set tbl = doc.Sections.First.Headers.Item(1).Range.Tables(1)

I cannot, however, get the Split() function to do what it's supposed to do.  If I read out the aData1() value as it goes it will read me the value of the entire row for each row.  If I replace "vbTab" with " " it isn't quite working right.

I can't really do much with it having the entire text of the row, is there an easier way to search for the specific text in the cell preceeding the text I want to use as the file name?

Thank you!

Can you put a copy of the document with the table in the header in a folder on your OneDrive that you set to be shared and place a link to that folder in a message back here so that we can see what it is that you have.  Also let us know exactly what you want to extract.
Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

2 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated July 22, 2022 Views 659 Applies to: