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!

Word macro - pop up a list of potential items to paste?

Status
Not open for further replies.

nickgrimmer

Technical User
Mar 24, 2007
2
US
Hi everyone,

I've got only a very basic understanding (OK, probably less than basic understanding) of programming & writing macros, so please bear with me. What I'd like to do should be fairly simple, but I've spent the last 5 hours searching through tons of stuff, all to no avail... I'm probably using the wrong terminology, so feel free to correct anything I write here!

I'm creating a macro for my law journal that will make citations easier for everyone. Whenever we cite another law journal article, we must use a very specific abbreviation of that journal's name (for example, "Houston Law Review" becomes "Hous. L. Rev."). There's only a hundred or so different journals, and I've made a list containing the full and abbreviated names of each.

So - the idea for the macro is this - first, the user positions the cursor wherever they'd like the citation to go. Then the user runs the macro, and some kind of box pops up that lists all of the potential journals & their abbreviations. The box would also have an "insert" and a "cancel" button, and it would be nice if I could also put something in it to allow the user easily find the entry they want (probably either: 1) a text entry box to allow the user to begin typing the journal name, and the list would then scroll to whatever they've typed, or 2) a list of letters A-Z (so that the user can select the first letter of the journal name). Once the user has highlighted the journal name/abbreviation that they'd like to insert, they'd simply click "insert."

If anyone has code resembling this, I'd be forever grateful. Or if y'all even know what kind of box this should be or any other helpful tidbits, it would go a long way in getting me where I need to be. Thanks a ton.
 
Should not be too difficult. This is the result of recording the insertion of a footnote:

Code:
Sub Footnote()

    With ActiveDocument.Range(Start:=ActiveDocument.Content.Start, End:= _
        ActiveDocument.Content.End)
        With .FootnoteOptions
            .Location = wdBottomOfPage
            .NumberingRule = wdRestartContinuous
            .StartingNumber = 1
            .NumberStyle = wdNoteNumberStyleArabic
        End With
        .Footnotes.Add Range:=Selection.Range, Reference:=""
    End With
    Selection.TypeText Text:="MyFootnote"

End Sub

You simply need a userform with a listbox or combobox that shows your citiations wedged in before the selection.typetext.
 
Thanks a bunch for the input. I ran the code you suggested, but I'm not sure it's what I was going after... I don't need the macro to actually make a footnote; it would be used whenever the user is already in a footnote & simply needs to insert the journal name.

Surely there's some code to this effect on the internet somewhere - it should be a fairly common need. I just have no clue what to search for... I've tried everything I can think of & keep hitting dead ends.

 
Interesting.

NO WHERE in the post is the word "footnote" found. In fact, you state:
first, the user positions the cursor wherever they'd like the citation to go
- my emphasis.

I am not being overly critical, but it is very helpful when you post, to post what you actually want. You can not make any assumption that we will know what that is.

You now state:
it would be used whenever the user is already in a footnote & simply needs to insert the journal name.

THAT would have be helpful to state at the start. It is, in fact, NOT "wherever" they want it to go...it is a very specific wherever.
I just have no clue what to search for...
this may have some relation to knowing what you are asking for.

So, I will try and ask for you.

It seems to me you are asking for either:

A) - something that allows easy choice from a list while the user is in the footnote, typing;

OR

B) - something that allows easy choice from a list, and will put it in a existing footnote.

Which is it? Or maybe it is something else.

It seems to be A, and if it is, then it is fairly easy. A straightforward userform, called from a shortcut key, or a macro button on a toolbar. The userform has a combobox with your listings, an OK button that inserts the listing item at the current selection (and remember A means you are IN the footnote), and a cancel button that bails.

Piece of cake. but it does helps if you are clear in stating precisely, exactly, what your needs are.

I would also like to point out that mintjulep was stating the same thing as I am.
You simply need a userform with a listbox or combobox that shows your citiations wedged in before the selection.typetext.
Which seems to be the answer.


A userform witha combobox with your listings. The only different is that my suggestion does not insert the footnote, it would simply insert the item from your list.

Something like:
tektips3.jpg


A basic combobox can be set to let the user type - say "d", and in this case, it would jump to the first "d" - Disney School of Outrageous Decisions.

Building the list is a simple array:
Code:
Dim Journals()
Journals = Array("Houston Law Review", _
"Harvard Law Review", _
"Hannah and Barbara Law Review", _
"Disney School of Outrageous Decisions")
You could hard code that into the userform, or have it read from an external text file.

Once th euser makes th eselection, and clicks Insert, the userform insert the appropriate text - also done as an array.
Out of curiosity...what phrase, or words, did you use for searching?




Gerry
My paintings and sculpture
 
I would also like to point out that for some commonly used phrases/references using AutoText would be handy.

The user types "hlr", hits F3, and "Houston Law Review" is typed in.

It is of course impractical for 100+ references - too many abbreviations to remember. However, it would be fast for the most common ones, if there are any.

Gerry
My paintings and sculpture
 
I don't know an awful lot about citations but I think you might be interested in taking a look at Word 2007 which seems to have built in functionality for most of what you ask.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

Professional Office Developers Association
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top