At the office I created a word-document linked to an excelfile to mailmerge data into the word document. Pretty easy. However, 3 other users need to use the same mailmerge documents. I make a copy of the worddocument and rootfile into a seperate folder for every user. So every time I make a change in the word document, I run a macro to save a copy to the folder of each user (we have access to each other folders) and I link the correct excelfile to Mailmerge correctly for each user. However if I select the excelfile as rootfile, for the other users it will not work since the code says:
ActiveDocument.MailMerge.OpenDataSource Name:= "C:\Users\Louisa\..."
I need something like:
ActiveDocument.MailMerge.OpenDataSource Name:= "C:\Users\CURRENT_USERNAME\..."
Is there a code in Word VBA to insert a current user?
My colleagues are really bad in everything IT, so for them it's confusing selecting the rootfile.
I've tried to insert the username of my colleagues in the macro: f.e.:
ActiveDocument.MailMerge.OpenDataSource Name:= "C:\Users\Sofie\..."
However I get an error, since I can't access "C:\Users\Sofie...
I'm new to VBA so all advice is really welcome!
Thank you!
The way I have done this is to keep both the merge documents and the data source in the Workgroup Templates folder which is updated to each user as part of a network login.
You can get the local location on each system for that folder through vba and use that as part of the path in your macro.