I’m a total newbie here. I have Word Document that has 15-20 pages with most information repeating. Over 20 fields are repetitive. I used bookmarks and cross-references to generate all the subsequent pages following the first two pages of just a table and bookmarks. My problem is that I cannot save the final version with the table of bookmarks in it. I have to delete those two pages. Deleting those pages means all the content becomes “Error! Reference source not found” when someone prints or saves.
First, I tried this script that I found on a website. The code actually meant I could SAVE the document and the data stayed intact, but would go to the Error! when printing:
Sub removebookmarks() Dim bkm As Bookmark For Each bkm In ActiveDocument.Bookmarks bkm.Delete Next bkm End Sub
Then, I tried these two scripts I found here on the forum hoping this would just drop the cross-references and keep the original data intact, but the data was still lost when printing and Error! on any PC that tried printing the document:
Sub UnlinkBookmarks() Dim aFld As Field For Each aFld In ActiveDocument.Fields If InStr(1, aFld.Code.Text, “LSU_”, 1) Then ‘Debug.Print aFld.Code.Text aFld.Unlink End If Next aFld End Sub
Sub UnlinkBookmarks() Dim i as integer For i = ActiveDocument.Fields.count to 1 step -1 If InStr(1, aFld.Code.Text, “LSU_”, 1) > 0 then ActiveDocument.Fields(i).unlink end if Next i End Sub
Unfortunately, I have the same “Error!…” coming up.
I’m totally clueless with VBA or any of this scripting. I’ve been reading and reading to no avail.
It’s entirely fine if all the hyperlinks and what not are removed. The only “links” are between bookmarks and cross-references. I just need the data to stay intact through all of the sections of this document and to remove those links so I can delete the bookmark “document generator” table as I like to call it.
I appreciate any help out there.