Help with hyperlink and macro

C

Corkey

Yet another problem that I am calling upon the experts to assist me with. We
use codes and explanations associated with the codes and I have created a
word document and make a page with code numbers and attached hyperlinks to
them so when you click on them, you go directly to the comments to copy. My
question is if there is some type of macro or something that I could
incorporate into the hyperlink that when they click on it, it automatically
copies the text so they do not have to go into the text box and highlight it
manually? Example:

Master Parking Reasons

02 UNABLE TO MATCH PO LINE(S)
03 CURRENCY MISMATCH
Once you click on one, it brings you to the appropriate text box with
comment such as below:

Unable to match invoice to PO line(s):
Unable to match description on vendor’s invoice to line(s) on PO
No assistance available from PO header text
Please handle exception(s)

If a macro is not possible, would there be a way to just associate the text
so when they click on the number, the text is automatically put on the
clipboard and they can adjust the text when the transfer it over?

Any advise would be greatly appreciated. This forum has helped me immensely!
 
G

Greg Maxey

Corkey,

Not sure that I fully understand your objective, but I think that you want
to click on some text and by doing so you automatically have some other
detailed text copied to the clipboard so you can paste it elsewere.

Lets say you have a single column multi-row table that contains your
detailed text. Each row contains detailed text for a specific item.

You could use macrobutton fields to list your items in the document. When
dblclicked, the macro fires copying the appropriate data to the clipboard.

{MacroButton CopyText 02 UNABLE TO MATCH PO LINE(S)}. The field will
display the only the text provided.


Sub CopyText()
Dim oTbl As Word.Table
Set oTbl = ActiveDocument.Tables(1)
Dim oRng As Word.Range
Dim oCellRng As Word.Range
Set oRng = Selection.Range
Select Case Mid(oRng.Fields(1).Code, 23)
Case "02 UNABLE TO MATCH PO LINE(S) " 'Note trailing space before end
quotes.
Set oCellRng = oTbl.Cell(1, 1).Range
oCellRng.End = oCellRng.End - 1
oCellRng.Copy
Case "03 CURRENCY MISMATCH "
Set oCellRng = oTbl.Cell(2, 1).Range
oCellRng.End = oCellRng.End - 1
oCellRng.Copy
End Select
End Sub
 
C

Corkey

Hi Greg,

I am sorry if I was not clear on my example. I think I might be able to do
it as you explained but might need a little more assistance. Right now I have
a word document with a main page containing the numbers associated with the
codes. The following sheets have text boxes with the comments that are needed
for each number. I will try to paste a better example at the end. Right now,
when you click on the appropriate number on the main page, the hyperlink will
bring you to the appropriate page with the comments that are needed. From
there, we manually highlight the text and copy it to bring it over to our SAP
comment screen (not compatible with Microsoft). It is standard wording so
that is why I was wondering if there was a way that when they clicked on 02
UNABLE TO MATCH PO LINE(S) – It will automatically copy the standard comment
so they can paste it over instead of them having to manually select it and
copy it to the clipboard. Originally I asked if it would take them to the
correct spot and then copy the text but that would not be necessary as the
main objective is to have the comments to bring over to the other system and
paste them in. I think I have a good concept of what you have suggested and I
will give it a shot and let you know how it works. Thank you very much for
your prompt and helpful response.

Now – one clicks on the hyperlink below on the main page
02 UNABLE TO MATCH PO LINE(S)
Then they are brought to the page with the appropriate comment as listed below

02 Unable to match po line(s)

Unable to match description on vendor’s invoice to
line(s) on PO. No assistance available from PO header text
Please handle exception(s)

Thank you.

We then highlight the text and copy it to bring it over to the other screen
to paste. It just seems that we are taking extra steps in doing this and it
seems that is an easier way. I hope this gives you a better understanding. I
could email you the actual sheet if it helped.

Thanks again.
 
G

Greg Maxey

Corkey,

The code I sent you should work. Instead of using textboxes to contain the
explanatory text just use a row in a table.

E.g,

Your Macrobutton field code is:

{ Macrobutton CopyText Item 1}

when the field code is toggled then only Item 1 is displayed.

When the user dbl-clicks the marobutton field then the macro is fired the
macros goes to the appropriate table row to copy the contents to the
clipboard. Users then simpy paste it where they want.




When the field
 
G

Gordon Bentley-Mix

Corkey,

This seems like an overly complicated approach to performing this task. If I
were to undertake this project, I would probably create an add-in that
incorporated a custom toolbar that did one of two things, depending on the
number of "codes":

* If there are only a few codes (less than 10), I would have a "menu" type
button on the toolbar with items for each code.

* If there are a lot of codes, I would display a UserForm with a ComboBox
or ListBox populated with a list of the codes.

In either case, I would set it up so that selecting a code (either from a
menu item or from the UserForm) would then insert an AutoText entry (stored
in the add-in) at the cursor location in the target document.

Neither method is especially difficult, and I could probably put together an
example add-in in less than an hour. In fact, I might just do it for the
challenge, and if this sounds like something you might be interested in,
contact me at the email address listed in my profile and I'll send it to you.
-----
Cheers!

Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 

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