I'm creating a form in MS Word for our customer service reps to fill out and then I want to have a submit button at the bottom of the page that will run a macro to automatically save the file in a desired directory and to use the customer's name as the file name. Is there a code to pull the information entered into a form text field and use it as the filename? This is what I have so far:

Private Sub SUBMIT_Click()

    ChangeFileOpenDirectory "Y:\Form Upload\"
    ActiveDocument.SaveAs FileName:=Range("A1").Value & Format(Date, "mmdd"), FileFormat:=wdFormatDocument, _
        LockComments:=False, Password:="", AddToRecentFiles:=False, WritePassword _
        :="", ReadOnlyRecommended:=True, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False

End Sub

...it should be noted I borrowed this from an excel, so I have the old file parameters in there

/bump

...is this even possible? would it perhaps be a better idea to use excel where i already know how to pull the data?

Hey there Scud

You are trying to mix 2 different coding languages together.

You need to either use word to create the form and and then run the macro you create or...

Use VB to create the form and use VB coding to save the text fields to where you want the info.

OR use VB to create the form and save to a .mdb

You could even use Access to do a similar job.

Hope this helps
Arty

basically I want the full file with the data to save in a directory on one of our servers so that our warehouse staff can pull the information... I dont need it to go into a database or anything, just want the file to save as the customer name so that its easier to find the right file when the warehouse is looking for it on the network drive... not sure if that made any sense, but yea, thats what I'm going for... (I'm a technician who they assume is also a programmer, so my knowledge about this stuff is very limited)

I am a programmer specializing in data storage..
using either Visual Basics and .mdb. I primarily use php/mysql.

So when dealing with lots of information it is unwise to use text files and random file names using customer names.
What happens if you end up with 20 John Smiths, or J. Smiths etc.

I assume the details being saved are orders to be processed by the warehouse?

If so, you really need a database so the information doesn't get corrupted and easier to save and access.

Please let me know what type of information you are wanting to store and for how long.

As sales or delivery details should be stored long term for referencing when required.

Regards
Arty

we have a full ERP system in place that handles all of the data for sales and what not. In this particular instance, one of our customers wanted to know more specifics about why their products were being sent back as defective so they designed a form they wanted customer service to fill out. Our reps would fill out the form, turn them into the supervisor and then they would take all the forms out to the warehouse where they would be matched up with the returned product to be shipped back to the manufacturer. They tasked me with making this form electronic so that it can be printed in the warehouse and inserted and then we can eliminate down time for customer service reps turning in forms and supervisors having to travel out to our warehouse.

My experience with electronic forms is very limited so I just tried to make one using MS Word, but they wanted it to save automatically to a specific drive so that our warehouse staff would have one place to look for the files. However, they want to eliminate the chance for a mistake on customer service's end by placing a "submit" button on the bottom of the form that automatically saves the file using the customer's name (easiest way to match up to returned product). Also, time is an issue.

I know that was pretty long winded, but hopefully you have a clearer understanding of what I'm trying to do. Looking forward to what ever advice you can offer.

Thanks for the explanation.

I can foresee woeful problems ahead of you without capturing this information correctly.
To just save text files to a hard-drive that can be accidentally deleted and never recovered is something that makes me shudder with horror that anyone would even consider this.

What you need is a way of matching the exact customer (purchaser of the item) from the original sale to the returned item. I know from experience that eventually if not sooner you are going to have 2 John Smiths on the exact same day; so how would you handle that. And worse still what if they returned the exact same item?

Now I need to know if the drive you are referring to is a networked drive on an intranet. Sounds like everyone is in the same building, so the likely answer is yes.

You really need a system that saves data about each return for history and reference sake.

Where you can look up any return for any purchaser quickly to see what has happened.

Now you can design an access database to store this information. which has limitations on the number of people that can be using it at anyone time. Microsoft limitation... only 1 connection allowed at any one time. So simultaneous connections is out of the question.

As the technician do you know if your server/computer you are going to save this information to, can handle php and a mysql database.

If not I can recommend a software solution (free) that will give you this ability. Then getting a programmer to convert your form into php and save the information from as u say a submit button.

Then you can have a warehouse admin console where; obviously the warehouse staff can login and view all the returns and do searches by name, area code, item returned, date returned or any search criteria you want.

This maybe long winded and not what you really want to read but believe me integrity of data in this day and age is paramount.

Regards
Arty

Hello, i want to do exactly what this fellow above is asking for. But with me, its not a problem if more than one people can't use it, cuz its gonna be saved on the same hard drive. And i prefer word format, if you please :)
And practically, I DON'T know a thing about macros and all, just little bit... not a programmer..

Thanks for the explanation.

I can foresee woeful problems ahead of you without capturing this information correctly.
To just save text files to a hard-drive that can be accidentally deleted and never recovered is something that makes me shudder with horror that anyone would even consider this.

What you need is a way of matching the exact customer (purchaser of the item) from the original sale to the returned item. I know from experience that eventually if not sooner you are going to have 2 John Smiths on the exact same day; so how would you handle that. And worse still what if they returned the exact same item?

Now I need to know if the drive you are referring to is a networked drive on an intranet. Sounds like everyone is in the same building, so the likely answer is yes.

You really need a system that saves data about each return for history and reference sake.

Where you can look up any return for any purchaser quickly to see what has happened.

Now you can design an access database to store this information. which has limitations on the number of people that can be using it at anyone time. Microsoft limitation... only 1 connection allowed at any one time. So simultaneous connections is out of the question.

As the technician do you know if your server/computer you are going to save this information to, can handle php and a mysql database.

If not I can recommend a software solution (free) that will give you this ability. Then getting a programmer to convert your form into php and save the information from as u say a submit button.

Then you can have a warehouse admin console where; obviously the warehouse staff can login and view all the returns and do searches by name, area code, item returned, date returned or any search criteria you want.

This maybe long winded and not what you really want to read but believe me integrity of data in this day and age is paramount.

Regards
Arty

Hello, i want to do exactly what this fellow above is asking for. But with me, its not a problem if more than one people can't use it, cuz its gonna be saved on the same hard drive. And i prefer word format, if you please
And practically, I DON'T know a thing about macros and all, just little bit... not a programmer..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.