Userform and MS Word

K

Kemp

I was wondering if it is possible to use a userform to fill in blanks on a
word file. Here what I am trying to do. I have a piece of script that I want
to be able to populte and copy. I am adding radio stations to an online radio
and to add stations I need to add this script for each station Example:

<station url="http://85.12.7.2:8000"> <---want to add http address
<name>DEFJAY</name> <---want to add name
<genre>RnB</genre> <---want to add genre
</station>
I want to be able to use the userform to populate the http address, name and
genre. So I would fill the boxes and click a button that would save this
script with the information. Everytime I enter the information it would add
another script entry
Example:
<station url="http://85.12.7.2:8000">
<name>DEFJAY</name>
<genre>RnB</genre>
<station url="http://123.32.7.2:8080">
<name>Crazy7</name>
<genre>Heavy Metal</genre>
<station url="http://124.08.63.9:3000">
<name>Whisper92</name>
<genre>Soft Rock</genre>
So when I am done I have a list that I can copy and paste into my site. I
hope this made sense. Is this possible? and if so how? I am a newbie when it
come to this stuff. Thank you for any insight :0)

Kemp
 
D

Doug Robbins - Word MVP

I would probably use a directory type mail merge and enter the data into the
data source file, which could be an Excel spreadsheet or a table in a word
document. You may however already have the information in some source file
that could be used.

--
Hope this helps,

Doug Robbins - Word MVP

Please reply only to the newsgroups unless you wish to obtain my services on
a paid professional basis.
 
G

Graham Mayor

As Doug suggests, much depends on where your source of the information is
located. It would certainly be possible to create a userform with three
fields to collect the data and write it with the tags into a document. For
the basics, see Word MVP FAQ - Userforms
http://word.mvps.org/FAQs/Userforms.htm

for a more in depth explanation, see
http://gregmaxey.mvps.org/Create_and_employ_a_UserForm.htm

But it might be quicker to enter the information in a three column table and
use mail merge to produce the list (as Doug suggests). Or if you have the
information in a list already you could either use mail merge or vba to
format the list to add the tags.

The most basic code for a userform using default field names would be

Private sURL As String
Private sName As String
Private sGenre As String
Private Sub CommandButton1_Click()
sURL = TextBox1.Value
sName = TextBox2.Value
sGenre = TextBox3.Value
ActiveDocument.Range.InsertAfter "<station url=""" & sURL & _
""">" & vbCr & "<name>" & sName & "</name>" & vbCr & _
"<genre>" & sGenre & "</genre>" & vbCr
Unload Me
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top