Results 1 to 7 of 7
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Hyperlinks or buttons ...?! (WinNT4, Word97)

    In this thread I was asking about a way to produce a document which contains simply a list of templates, with two links, one to open a document to view, the other to run the template, but the only way we have been able to come up with so far involves a macro for each template I want to run. Unfortunately, since I'm talking about a dozen departmental lists containing a total of some 2500 template names this really would not be practical, in terms of ongoing maintenance.

    However, I had a vague thought that perhaps one could write a generic macro that picks up the name of a bookmark when it's clicked on and uses that name as the name of the template it is to open - through a macrobutton, perhaps, although I haven't had a chance to look into these and find out exactly how they work yet.

    Does anyone out there think this is feasible and could perhaps point me in the right direction to set it up?
    Beryl M


  2. #2
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks or buttons ...?! (WinNT4, Word97)

    I have been trying to find a way to do this myself, and have got as far as the attached doc, using this sub ...

    Sub RunTemplate()
    Dim tableRow As Long, templateName As String
    tableRow = Selection.Tables(1).RowIndex
    templateName = Selection.Tables(1).Cell(tableRow, 1).Range
    Documents.Add Template:="FLEETVOL5DATATEMPLATE_1stPersonmanagers " + templateName + ".dot", NewTemplate:=False
    End Sub

    ... and a macrobutton, but I can't find out if the sub works because I can't get the macrobutton to work! My macrobutton looks like this ...

    { MACROBUTTON RunTemplate >> }

    ... and I've tried it protected and unprotected but nothing makes it run the macro!

    <img src=/S/please.gif border=0 alt=please width=31 height=23> Could someone *please* tell me where I'm going wrong?! <img src=/S/please.gif border=0 alt=please width=31 height=23>
    Attached Files Attached Files
    Beryl M


  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hyperlinks or buttons ...?! (WinNT4, Word97)

    To activate a macro button, you must double click it. I downloaded your doc and I could start the macro, but...

    You use RowIndex - it's a property of a table cell, not of a table, so Tables(1).RowIndex will fail. Hopefully somebody else knows how to find out the RowIndex of the "ActiveCell".

  4. #4
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks or buttons ...?! (WinNT4, Word97)

    Thanks, Hans, it was the double-clicking bit I was missing!

    Unfortunately, even if someone tells me how to retrieve the active cell's rowindex (and I'd still love to know, please, anyone?!), I've a feeling that doubleclicking on a macrobutton won't qualify as making its cell the 'active cell'!

    OK, next thought - If I surround the macrobutton with a bookmark, is there a way to retrieve the name of the bookmark that's just been clicked on?!

    Pretty please!!
    Beryl M


  5. #5
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks or buttons ...?! (WinNT4, Word97)

    <img src=/S/joy.gif border=0 alt=joy width=23 height=23> I got it! <img src=/S/joy.gif border=0 alt=joy width=23 height=23>

    The line I needed to get the bookmark was 'selection.bookmarks(1).name'.

    However, it seems double-clicking *does* put the selection in the cell and make it active, so I would still very much like to know how to return the rowindex of the activecell, if anyone out there knows, please? It would make it much more elegant and far simpler if I didn't have to worry about putting the bookmarks in!

    Many thanks!
    Beryl M


  6. #6
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks or buttons ...?! (WinNT4, Word97)

    Final note: in case anyone else is trying this, you need one more line of code to make it work - one to strip the two unwanted characters from the end of the table cell's contents that are, presumably, the end-of-cell markers. I did it like this:

    Sub RunTemplate()
    Dim tableRow As Long, templateName As String, tableRange As String
    tableRow = Selection.Cells(1).RowIndex
    tableRange = Selection.Tables(1).Cell(tableRow, 1).Range
    templateName = Left(tableRange, Len(tableRange) - 2)
    Documents.Add Template:="FLEETVOL5DATATEMPLATEmanagers" + templateName + ".dot", NewTemplate:=False
    End Sub

    There's probably a more elegant way to do it, but this works!

    Many thanks to all for your help!
    Beryl M


  7. #7
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Morden, Surrey, United Kingdom
    Posts
    1,838
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Re: Hyperlinks or buttons ...?! (WinNT4, Word97)

    <img src=/S/clever.gif border=0 alt=clever width=15 height=15> Wow, I'm really on a roll today! I worked out the line to return the activecell's rowindex! <img src=/S/bullseye.gif border=0 alt=bullseye width=45 height=15> It's:

    Selection.Cells(1).RowIndex

    It was that bit about having (1) at the end of both the 'bookmarks' and the 'cells' reference that was holding me up.

    <img src=/S/brainwash.gif border=0 alt=brainwash width=15 height=15> Now if I can just remember that long enough for the next time I get stuck on something similar ...!
    Beryl M


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •