Pulling sentences in a menu from a text file - please any ideas !

G

gravesen

HI I have a little question that I would very much like some help with
I have a toolbar in word and when moving the mouse over a button I hav
some sentences that I can insert into the document. The are made wit
macros that are recorded but I would like to update this and add mor
without having to add these from/in the vba.

When I click a sentence in one languge the sentence is inserted i
English in my word document. If I move my cursor over the sentence thi
is translated with the comment.

What I would like is to pulle these macros from a text file o
something and be able to add more sentence in a nice and easy way.

This is the macro I use for inserting a sentence with comment:
------------------------------------------------------
Sub DendanskeambassadeiWashington()
'
' DendanskeambassadeiWashington Makro
' Makro indspillet 27-01-2004 af
' "&chr(10)&"lgr
'
Selection.TypeText Text:= _
"The Danish Embassy in Washington has recommended that w
contact you. "
Selection.Comments.Add Range:=Selection.Range
Selection.TypeText Text:="Den danske ambassade i Washington ha
anbefalet, at vi kontakter Dem."
ActiveWindow.ActivePane.Close
End Sub

____________________________________________


When I start on a letter there are a guide (form) where I can inser
data on who the letter is for and so on and when clicking ok the dat
is inserted. I have made it so that I can write these data in a tex
file and read them everytime the document is run. I belive that this i
a little like what I have to make for the pulling of the buttons a dat
or perhaps I am wrong.

This is what I use for reading data to my starting data screen where
can insert the data and the data from the text file is loaded.

-------------------------------------------------
Private Sub UserForm_Activate()
Dim iLin As Integer ' a counter for lines
Dim sTxt As String ' the text from a line
Open "c:\easyletters\config.txt" For Input As #1
For iLin = 1 To 2 ' in case there are 5 lines
Input #1, sTxt ' get the text from the line
' MsgBox sTxt ' for testing
Input #1, sTxt
txtafsendernavn.Text = sTxt
Input #1, sTxt
txtafsenderadresse.Text = sTxt
Input #1, sTxt
txtafsenderpostby.Text = sTxt
Input #1, sTxt
txtafsenderland.Text = sTxt
Input #1, sTxt
txtafsendertlf.Text = sTxt
Input #1, sTxt
txtafsenderfax.Text = sTxt
Input #1, sTxt
txtafsenderemail.Text = sTxt
Input #1, sTxt
txtafsenderwww.Text = sTxt
Input #1, sTxt
txtvoresref.Text = sTxt
Input #1, sTxt
txtnavn.Text = sTxt
Input #1, sTxt
cbostilling.Text = sTxt

Next
' or

'Input #1, sTxt
'TextBox2.Text = sTxt
'...
Close #1
End Sub

---------------------------------------------------



Hope U understand what I mean !
Any help would make me so happy :)

Kind Regards
Lars Gravese
 
H

Helmut Weber

Hi Lars,
I think what you need is a userform with some
listboxes, from which to pick the sentences,
and the comments, or both at once. If the userform
is of kind vbmodeless, you could navigate through
you document, go back to the form, pick a sentence,
have it inserted, navigate further and repeat
all as often as you want. Try to create a macro
first, that open a userform, and fill a listbox
from a txt-file, for example, as a first step.
 

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