By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,460 Members | 2,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,460 IT Pros & Developers. It's quick & easy.

Can I assign the value of a variable to a filename ?

P: n/a
Hello all,
I have made a form which takes input from the user (things like name,adress,
reference number and so on). After filling in the form, the user presses a
button. The program then takes all the values out of the controls, opens MS
Word and uses these values to compose a letter with all the data pre-filled
in. Now my question is : Can I make a variable, containing some text which
comes out of the controls of the form and use this variable to define the
filename?
do it would look like :
*****
Me!Myform!Textbox1.value = "Myname"
Me!Myform!Textbox2.value= "EG"
Me!Myform!Textbox3.value= "JK"
Dim sNameFile as String
sNameFile = Me!Myform!Textbox1.value & "_"& Me!Myform!Textbox2.value & _
"_" & Me!Myform!Textbox3.value
*****
So now sNameFile contains the name with which the file shoul be saved. Thus
on disk, in the explorer the file should look like : Myname_EG_JK.doc
Is this possible and what is the correct syntax ?
Save as .............
Can anybody help me with this ?
Thanks !!!!


Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Ronny Sigo" <ro********@skynet.be> wrote in message news:<3f***********************@reader0.news.skyne t.be>...
Hello all,
I have made a form which takes input from the user (things like name,adress,
reference number and so on). After filling in the form, the user presses a
button. The program then takes all the values out of the controls, opens MS
Word and uses these values to compose a letter with all the data pre-filled
in. Now my question is : Can I make a variable, containing some text which
comes out of the controls of the form and use this variable to define the
filename?
do it would look like :
*****
Me!Myform!Textbox1.value = "Myname"
Me!Myform!Textbox2.value= "EG"
Me!Myform!Textbox3.value= "JK"
Dim sNameFile as String
sNameFile = Me!Myform!Textbox1.value & "_"& Me!Myform!Textbox2.value & _
"_" & Me!Myform!Textbox3.value
*****
So now sNameFile contains the name with which the file shoul be saved. Thus
on disk, in the explorer the file should look like : Myname_EG_JK.doc
Is this possible and what is the correct syntax ?
Save as .............
Can anybody help me with this ?
Thanks !!!!


Ronny,
sure. This is cake. You just build the filename (be sure to include
the full path), so your full path would be something like:

C:\Dir1\SubDir1\Filename.doc

as long as you have that built, you can pass that value to your Word
automation stuff and just do something like

appWord.SaveAs strSaveFile

(Sorry, can't remember the exact syntax in Word...)

HTH a little,

Pieter
Nov 12 '05 #2

P: n/a
Thank you :)
I will only be able to try this tomorrow, but I am sure this will work !

"Ronny Sigo" <ro********@skynet.be> wrote in message
news:3f***********************@reader0.news.skynet .be...
Hello all,
I have made a form which takes input from the user (things like name,adress, reference number and so on). After filling in the form, the user presses a
button. The program then takes all the values out of the controls, opens MS Word and uses these values to compose a letter with all the data pre-filled in. Now my question is : Can I make a variable, containing some text which
comes out of the controls of the form and use this variable to define the
filename?
do it would look like :
*****
Me!Myform!Textbox1.value = "Myname"
Me!Myform!Textbox2.value= "EG"
Me!Myform!Textbox3.value= "JK"
Dim sNameFile as String
sNameFile = Me!Myform!Textbox1.value & "_"& Me!Myform!Textbox2.value & _
"_" & Me!Myform!Textbox3.value
*****
So now sNameFile contains the name with which the file shoul be saved. Thus on disk, in the explorer the file should look like : Myname_EG_JK.doc
Is this possible and what is the correct syntax ?
Save as .............
Can anybody help me with this ?
Thanks !!!!

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.