Saving an open word document to a specific file directory with user input for file name

fireman112473

New Member
Joined
May 9, 2017
Messages
8
I am trying to create a macro that will allow me to open a word file and immediately save it as a new file in a specific file directory. Below is how far I have gotten. I can save to a specific file directory with a predetermined name, but can't get it to allow for user input for new file name.

Sub IL09NFPA722010()
Documents.Open FileName:="S:\Data\FORMS\Master Plan Review Letters\2009 IBC and MBC Forms\Illinois\IL Alarm PR Letter IBC 2009 NFPA 2010.docx", ReadOnly:=True
ActiveDocument.SaveAs FileName:="S:\Employee Folders\Scott McBride\0 2017 Plan Review Letters" & "doc1", Fileformat:=wdFormatXMLDocument
End Sub

I want a user input for the area shown in bold.

Thanks
Scott
 
Is this code in an Excel module?
No I am doing this in word. Our process is that we open a letter template from the server. Then saveas with a new name in a differenr folder on the server and the customize it for the purposes at hand.

I want to open word choose my template, saving the file with a new name in an existing folder, and saved file remaining open to customize accordingly. There are many people accessing these templates and trying to remove the temptation to do a save vs saveas.

Cant get the new file to remain active. It saves it, but the I have to manually open it.

Getting closer.
 
Upvote 0

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Well, as this forum is called MrExcel - I don't know how they feel about Word questions - but I'm sure the mods will answer that one.

Regardless, it would have been helpful to clarify that from the beginning. I made the assumption it was all for Excel, accessing Word from outside.

Unfortunately, I don't do much coding in Word, so I'm not sure I can be of further help.
 
Upvote 0
Our process is that we open a letter template from the server. Then saveas with a new name in a differenr folder on the server and the customize it for the purposes at hand.

I want to open word choose my template, saving the file with a new name in an existing folder, and saved file remaining open to customize accordingly. There are many people accessing these templates and trying to remove the temptation to do a save vs saveas.
The problem, though, is that you're not actually using a template. What your code shows you're actually doing is opening an existing Word document, which you're then trying to save with a new name. The file:
"S:\Data\FORMS\Master Plan Review Letters\2009 IBC and MBC Forms\Illinois\IL Alarm PR Letter IBC 2009 NFPA 2010.docx"
is a Document, not a Template, and you're opening it using Documents.Open. If you were using a Template, it would have a .dotx or .dotm extension and, instead of using Documents.Open, you'd use Documents.Add. For example:
Documents.Add "S:\Data\FORMS\Master Plan Review Letters\2009 IBC and MBC Forms\Illinois\IL Alarm PR Letter IBC 2009 NFPA 2010.dotx"
When you create a new document from a Template, there is negligible risk of it being overwritten by the document created from it. Indeed, if you were using a Template, there wouldn't be any need for a macro such as the one you're trying to use to protect it. Try saving your 'IL Alarm PR Letter IBC 2009 NFPA 2010' as a Template, via File|Save As, then close Word (or at least the template) and double-click on the template to see what happens.
 
Last edited:
Upvote 0
A nanosecond looking at the discussions in this forum would answer that - positively.
Being text, I can't tell if this is snark or not, and I honestly can't even tell which way you're answering.


While I'm not a terribly active member, I've been here a while, and I can't say I have ever come across any mention of Word while poking through these questions, so I truly had / have no idea how it is received here.
 
Last edited:
Upvote 0
Well, the thread currently adjacent to this one is titled 'Automatically saving a text file (created with a macro from csv) as Word.doc silently' and simply scrolling down the thread list for this forum shows plenty of others referencing Word in their titles, too.
 
Upvote 0
The problem, though, is that you're not actually using a template. What your code shows you're actually doing is opening an existing Word document, which you're then trying to save with a new name. The file:
"S:\Data\FORMS\Master Plan Review Letters\2009 IBC and MBC Forms\Illinois\IL Alarm PR Letter IBC 2009 NFPA 2010.docx"
is a Document, not a Template, and you're opening it using Documents.Open. If you were using a Template, it would have a .dotx or .dotm extension and, instead of using Documents.Open, you'd use Documents.Add. For example:
Documents.Add "S:\Data\FORMS\Master Plan Review Letters\2009 IBC and MBC Forms\Illinois\IL Alarm PR Letter IBC 2009 NFPA 2010.dotx"
When you create a new document from a Template, there is negligible risk of it being overwritten by the document created from it. Indeed, if you were using a Template, there wouldn't be any need for a macro such as the one you're trying to use to protect it. Try saving your 'IL Alarm PR Letter IBC 2009 NFPA 2010' as a Template, via File|Save As, then close Word (or at least the template) and double-click on the template to see what happens.

I misspoke. I am not using a template either. It is a word document that we are opening. Multiple users are accessing these documents. everything is happening that I need it to do from I just need to be able from Delfinus25's assistance except for keeping the file open for further editing. It is getting caught up at the .activate.

Any ideas of how to resolve?

Thank you.
 
Upvote 0
You want to keep the newly saved document open?

What about just REOPENING it after saving? Might that be a suitable workaround?
(Once again, I don't really do Word VBA, I have no idea how much it differs)
 
Upvote 0
I misspoke. I am not using a template either. It is a word document that we are opening. Multiple users are accessing these documents. everything is happening that I need it to do from I just need to be able from Delfinus25's assistance except for keeping the file open for further editing. It is getting caught up at the .activate.

Any ideas of how to resolve?
Your reply quoted the optimal solution. You might at least try it.
 
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,635
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top