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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A little more than a regular hyperlink....

Status
Not open for further replies.

pendle666

Technical User
Jan 30, 2003
295
GB
Hello everyone,

I'm writing a set of procedures for the work that I do. I work in payroll so everything is repeated week after week.

In my text I'm writing things like

"Open up the bacs.doc which will give the total." Now bacs.doc is a file which can be found in

\payrun\wk 40
\payrun\wk 41
\payrun\wk 42

and will be automatically created each week by the system.

I'd like to include bacs.doc as a hyperlink because anyone could be using the notes to do the work. Is there any way with a bit of magic that the hyperlink can be made to look at the latest week?

thanks

Pendle

thank you for helping

____________
Pendle
 
Without knowing the application you have the hyperlink, it's difficult; but you may be able to do this with a macro
 
You say:

In my text I'm writing things like
"Open up the [blue]bacs.doc[/blue] which will give the total."

And I assume you want the text in BLUE to be a hyperlink
So where does this 'text' appear? What application? And how do you make it heppen?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Sorry!! Should have said. I'm writing my procedures in Word 2013. [highlight #5C3566]bacs.doc[/highlight] would be the hyperlink yes. If it was just a static file, then I'd just use Insert Hyperlink, but bacs.doc will be created each week we run the payroll. So next week's will be in folder week 43.



thank you for helping

____________
Pendle
 
What about my last question: "And how do you make it heppen?"
Is that in VBA in Word?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Hello

In the Word document, from the Insert tab, choose hyperlink, then at the top of the box type in what you want it to read - eg "click here" and in the bottom bit navigate to where the file you want to open is.


There's no VB involved in doing a straightforward hyperlink in Word. What I want to do is when clicking the hyperlink called bacs.doc, that it opens the latest weeks version which would live in \payroll\week 42\bacs.doc




thank you for helping

____________
Pendle
 
So WHEN does week 43 become available? HOW would that logically be determined?
 
Maybe a macro which would run when the Word document with hyperlink is open:

Code:
Dim [blue]strFileToOpen[/blue] As String
[green]
'Some logic needed here to determine which file to choose
'In short - the answer to Skip's question[/green]

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _[blue]
    strFileToOpen[/blue], SubAddress:="", ScreenTip:="", _
    TextToDisplay:="Click to open bacs.doc "

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Hello Skipvought

Week 43 starts on the Monday morning. I wouldn't actually use these documents until the Tuesday or a Wednesday though.



thank you for helping

____________
Pendle
 
Week 43 starts on the Monday morning" - so the question is: what day/date does the week 1 start?
April 7th 2014 was week 1?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Hello - yes, week 1 was April 7th 2014.

thanks

thank you for helping

____________
Pendle
 
bacs.doc is a file which can be found in
\payrun\wk 40
\payrun\wk 41
\payrun\wk 42"

Is that:[tt]
...
SomeServer\...\payrun\wk 40\bacs.doc
SomeServer\...\payrun\wk 41\bacs.doc
SomeServer\...\payrun\wk 42\bacs.doc
...
[/tt]




Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
So assuming your structure looks like:
[tt]
SomeServer\...\payrun\wk [blue]1[/blue]\bacs.doc
SomeServer\...\payrun\wk [blue]2[/blue]\bacs.doc
...
SomeServer\...\payrun\wk [blue]51[/blue]\bacs.doc
SomeServer\...\payrun\wk [blue]52[/blue]\bacs.doc
[/tt]
and your (Fiscal?) Year starts on April 1st, I will still use my VBA code from previous post since only week number in [blue]BLUE[/blue] needs to change:

Code:
Dim strFileToOpen As String

strFileToOpen = "SomeServer\...\payrun\wk " & [blue]WeekNumberFromApril_1st[/blue] & "\bacs.doc"

ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
    strFileToOpen, SubAddress:="", ScreenTip:="", _
    TextToDisplay:="Click to open bacs.doc " 
[blue]
Function WeekNumberFromApril_1st() As Long
Dim datApril1st As Date

If Month(Date) < 4 Then
    datApril1st = CDate("4/1/" & Year(Date) - 1)
Else
    datApril1st = CDate("4/1/" & Year(Date))
End If

WeekNumberFromApril_1st = Int(((Date - datApril1st) + 6) / 7) + Abs(Weekday(Date) = Weekday(datApril1st))

End Function[/blue]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Excellent, thanks for that. I shall give it a go this week.

thank you for helping

____________
Pendle
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top