Well here's what I ended up doing and it seems to work fine...
The SaveTo_Click is the code on the button. It calls SpecialClose to delete the button from the saved-as document.
Not pretty but it works. All the tektips are greatly appreciated folks!!
Private Sub SaveTo_Click()
Dim docFname...
You make a logical point. I was hoping the user could "camp" in the document template and keep saving new ones after they change the names and date on the form but it's not a requirement.
I am going to use a docm file instead of dotm to start with and just protect the docm file to make it a...
@TonyJollans
Thanks! That helped me get beyond the Content Control issue. The MyCC.Range.Text even worked for a Date control.
The SaveAs doc seems to remain open after this, so how to close it? ActiveDocument.close closes the template that has this code in it.
Private Sub SaveTo_Click()
Dim...
Maybe I should also ask... is there a better, less obtuse way to do this?
I want the users to fill several fields on a form (template) and click a button to saveas a DOCX to a specific location with a file name based on values in some of the fields.
Thanks, obtuse is a nice word for it!
With this code I get a blank MsgBox.. am I passing args ok?
Private Sub SaveTo_Click()
'ActiveDocument.SaveAs FileName:="c:\scripts\invoice\filex" & " " & Format(Date, "mm-dd-yy")
'MsgBox (ActiveDocument.ContentControls.Count)
'MsgBox...
I inserted 2 Plain text content conrols and one Date control from the Developer - Controls menu bar.
Then I added a Command button from the Controls - ActiveX controls menu
Yes.
activedocument.fields. gives options of methods
activedocument.fields( gives options of Index (long)
Msgbox(activedocument.fields.count) says just 1 (one) which the command button not the 3 "fields" text boxes I places on the document.
Msgbox(activedocument.fields(1)) gives CONTROL...
... also the Watch window in VBA, when I specify to watch LName it says <Expression not defined in context>
It's on the document, but apparently that isn't "defined" ?
@mintjulep, With your line I get "Method or Data member not found."
.Text is not valid
ALmost any valid one I select gives a type mismatch error.
...more hair lost.
Hi folks...pulling my hair out for hours on this seemingly simple task... trying to save a template as a docx file to a specific location and file name based on some text fields in the document.
In a MS Word template file, I have a text box control labeled LName. There's also a button named...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.