[WORD] (2016) Automatically exporting AutoText from Normal.dotm
So for starters, I'm not exactly versed in VBA, that is to say, I basically don't know anything about it. All I have is some python knowledge, but as luck would have it, I've been tasked with finding a way to automatically export AutoText from a Normal.dotm via VBA as this Normal.dotm being replaced by a new Normal.dotm. At first, I wanted to do it via saving AutoText from the Normal.dotm into the Building Blocks.docx, as is possible per the Organizer, but I've not found a way to automate this. Hence, I wanted to settle for just extracting the AutoText from the Normal.dotm in general (for now).
After some digging around, I found that there's a method that technically does exactly that; the "Application.OrganizerCopy" method. However, no matter how I use it, it just refuses to actually copy anything. I've even put a counter that goes up by one for each autotext that should theoretically be copied, and it counts all AutoTexts correctly - but in the end, when I check the file I gave the method as destination, there's nothing. 0kb. Empty. I'm honestly at my wit's end. Below is my code:
Sub CopyAutoText()
Dim atEntry As AutoTextEntry
For Each atEntry In _ NormalTemplate.AutoTextEntries I = I + 1 Application.OrganizerCopy _ Source:=NormalTemplate.FullName, _ Destination:="C:\Users\User\Documents\test.dotm", Name:=atEntry.Name, _ Object:=wdOrganizerObjectAutoText Next atEntry MsgBox (I)
End Sub
This code runs without any issues. It even correctly displays the amount of autotexts I put into my Normal.dotm for testing purposes (9). But in the end, *test.dotm* is still completely empty. I've tried with having both dotms open, I've tried with *Documents Close (SaveChanges)*, I've tried with different filenames, locations, word opened as administrator, everything I could think of, but it still won't work.
If anyone has any idea what I'm doing wrong, I would appreciate it a LOT.