RobBroekhuis
Technical User
Hi,
I'm writing a short application that requires some data storage (just a few filenames) that gets retained when the Office application is shut down. In Excel that's easy - I just write to ThisWorkbook in personal.xls. Now I'm trying to do the same in Word, figured out how to store things in ThisDocument in normal.dot, only to find that, since ThisDocument is used as a template for new documents, this isn't such a great idea.
Question #1: Is there a different convenient location to write to, without using a separate text file?
Question #2: I decided to try to do this by modifying the code in the module I'm writing (in normal.dot) on the fly. I've heard this is tricky, but I figured I'd give it a go. Problem is, VBE doesn't seem to know how to handle this. My code example:
VBE says I have a syntax error in the .replaceline line ("Compile error: expected =", but the replaceline method does not return a value, so that I get a run-time error if I try to fool VBE by adding "x=" to the line. Why is VBE confused? Do I need to add a reference? By the way, the .find line has a similar problem (syntax error when I leave the "b =" out), but luckily that method does return a value so that I can assign it to a dummy variable.
I'd appreciate your help!
I'm writing a short application that requires some data storage (just a few filenames) that gets retained when the Office application is shut down. In Excel that's easy - I just write to ThisWorkbook in personal.xls. Now I'm trying to do the same in Word, figured out how to store things in ThisDocument in normal.dot, only to find that, since ThisDocument is used as a template for new documents, this isn't such a great idea.
Question #1: Is there a different convenient location to write to, without using a separate text file?
Question #2: I decided to try to do this by modifying the code in the module I'm writing (in normal.dot) on the fly. I've heard this is tricky, but I figured I'd give it a go. Problem is, VBE doesn't seem to know how to handle this. My code example:
Code:
Sub addFF()
Dim l As Long, c As Long, ll As Long, lc As Long, b As Boolean
With Application.VBE.VBProjects("normal").VBComponents("Frequentfiles").CodeModule
b = .Find("FrequentOpen" & 1, l, c, ll, lc)
.ReplaceLine(l + 5, " Documents.Open c:\autoexec.bat")
End With
End Sub
I'd appreciate your help!