Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stripping userform textbox field to name document

Status
Not open for further replies.

Anthony904

IS-IT--Management
Jul 15, 2004
153
US
Current-
I have a word 97 template (dot) that users open to fill in data. Data is entered with the use of userforms. When a user opens up the template the document is named "Document1". User completes the form and clicks save as, names the document and stores it in a shared folder.

What I want-
I would like to automate the naming of the document.

Example: When a user opens the blank template they are instructed to fill in what Product A and what Product B is (on the userform). I would like to strip what the users entered in those two fields and name it as the new document. (ie.. "ProductA_to_ProductB.doc")

I do have a shared folder that these .doc are to be stored if needed.

I'm open to any other ways of doing this.

Thanks!


 



Sounds peachy to me?

Is this a question related to WHAT or HOW?

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 



Well can you post the code for your way, so we might have a stab at, "...other ways of doing this."

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Something along the lines of:

Code:
myDocument_full_path = "ThePath\where\I\want\TheFile\" & Product_A.Value & "_to_" & Product_B.Value & ".doc"
ActiveDocument.SaveAs FileName:=MyDocument_full_path
 
And you might want to activedocument.attachedtemplate = "" before you save.
 
Setting the attachedtemplate to null prevents Word from trying to open a reference to the original template anytime the created document is opened in the future.

If you don't, Word will try to find a way to open the reference, which can delay the opening of the document until a way is either found, or Word gives up.

Not a problem if the template is local, or on a fast network, but if are working on a laptop, WiFi in some hotel or Starbucks, with VPN back to the office, it can really slow things down.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top