Create new file and place it in certain directory

I have a button and need code to run a dotx (WORD NEW FILE template) and give the resulting new file a certain name ("New H file", for instance) and place it in the open lister.

I have read and tried, but is now running in circles. Can I get some help? Thanks!

Hans L

Is this the same thing you were trying to do 8 years ago?

Yes. Leo, it is (you have a good memory :-). I have lived with getting new, empty docx documents that need quite a lot of changes before I can use them, but now, I have gotten tired of it. I rememberhat someone (you, probably) said something about creating a button, which I did earlier today, and while I have a working dotx file, I have problems figuring out how to get it to open a file in the current lister and with a custom name.

I read something in the Help about not bothering with FileType, but just open the file and get on with it. Seemed to make sense, but it is this thing with path and name.

Do you have any tips?

Hans L

Not memory as much as searching for the forum for dotx. There are a few threads with people doing different things with them.

If you just want to copy the .dotx file to a fixed name in the current folder, all you need is the Copy command for that.

Copy "C:\the\template\path\xyz.dotx" HERE AS "My New File.docx"

(Assuming .dotx files are just .docx ones with a different extension.)

Thank you, Leo. However, when I run that in the key, while the file is created, when I try to open it, I get this error message:

Microsoft Word: The file "My New fFile.docx cannot be opened because there are problems with the contents." And no details.

However, I think I have to OPEN the template file (.dotx) HERE AS "My new file.docx".

Would that change the 'code'?

Hans L

Maybe Word template files aren't the same as normal documents. I don't know, to be honest. Your other thread had you running Word with the /t argument to do something with template files.

Do you need to use a template file? Why not just make a normal document with what you want, put it somewhere, and make a button which copies that to the current folder?

Leo. the reason I do not modify Normal is that it comes back "normal' after every update. Now, Word 2010 is probably not updated anymore, but pretty soon, I will get the latest MS Officer, and then I am back to square one.

Best,
Hans L

I mean a regular .docx file, not the template named “normal”.

Just make a .docx file somewhere with what you want in it, and a button that copies it to the current folder. There’s no reason to use template files here that I can see; they only help when creating the new document inside Word itself.

Aha, I see. I got a little hung up on templates. I'll try. Seems like a very good 9and simple (:slight_smile: idea.

Hans L

And, of course it worked. So simple, and so appreciated!!!

Hans L

1 Like