By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,460 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

Command to test for success of FollowHyperlink

P: n/a
I could not find this in the help file, so here goes...

I have some code that opens a word doc which is then set to a variable
called Target. Then a FollowHyperlink opens another word doc that is set to
a variable called Source. The "Source" data is copied and pasted to
"Target" and then "Source" is closed.

This runs in a loop and gets the contents of several word docs copied into
one place. But my code is very simple and relies on all files being
present - if a word doc is missing, then the Target is set as Source and
things do not go well.
For iCtr = 1 To UBound(FundPerfArray)
link = PathMod.FirstPath & "Company Folders\" &
FundPerfArray(iCtr).strTicker & "_" & FundPerfArray(iCtr).strFund_Name &
".Doc"

FollowHyperlink (link) ' this works if the file is present, but
what if it is not

Set oWordDocSource = oWord.ActiveDocument
oWordDocSource.Activate
oWordDocSource.Bookmarks(1).Select
oWord.Selection.WholeStory
oWord.Selection.Copy
oWordDocTarget.Activate
oWord.Selection.Paste
oWordDocSource.Close
Set oWordDocSource = Nothing
Next iCtr
What can I do to test if the FollowHyperlink(link) is successful? I assume
that if the test failed the resolution would be "Exit For" ?

Thanks
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Easy enough to test if the file exists. Just use Dir$() before you hyperlink
to the file.

If you want more control over what happens, you could try ShellExecute
rather than FollowHyperlink. Details:
http://www.mvps.org/access/api/api0018.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:1jZic.35329$IW1.1608553@attbi_s52...
I could not find this in the help file, so here goes...

I have some code that opens a word doc which is then set to a variable
called Target. Then a FollowHyperlink opens another word doc that is set to a variable called Source. The "Source" data is copied and pasted to
"Target" and then "Source" is closed.

This runs in a loop and gets the contents of several word docs copied into
one place. But my code is very simple and relies on all files being
present - if a word doc is missing, then the Target is set as Source and
things do not go well.
For iCtr = 1 To UBound(FundPerfArray)
link = PathMod.FirstPath & "Company Folders\" &
FundPerfArray(iCtr).strTicker & "_" & FundPerfArray(iCtr).strFund_Name &
".Doc"

FollowHyperlink (link) ' this works if the file is present, but what if it is not

Set oWordDocSource = oWord.ActiveDocument
oWordDocSource.Activate
oWordDocSource.Bookmarks(1).Select
oWord.Selection.WholeStory
oWord.Selection.Copy
oWordDocTarget.Activate
oWord.Selection.Paste
oWordDocSource.Close
Set oWordDocSource = Nothing
Next iCtr
What can I do to test if the FollowHyperlink(link) is successful? I assume that if the test failed the resolution would be "Exit For" ?

Thanks

Nov 12 '05 #2

P: n/a
Thanks

"Allen Browne" <Al*********@SeeSig.Invalid> wrote in message
news:40***********************@freenews.iinet.net. au...
Easy enough to test if the file exists. Just use Dir$() before you hyperlink to the file.

If you want more control over what happens, you could try ShellExecute
rather than FollowHyperlink. Details:
http://www.mvps.org/access/api/api0018.htm

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:1jZic.35329$IW1.1608553@attbi_s52...
I could not find this in the help file, so here goes...

I have some code that opens a word doc which is then set to a variable
called Target. Then a FollowHyperlink opens another word doc that is set
to
a variable called Source. The "Source" data is copied and pasted to
"Target" and then "Source" is closed.

This runs in a loop and gets the contents of several word docs copied

into one place. But my code is very simple and relies on all files being
present - if a word doc is missing, then the Target is set as Source and
things do not go well.
For iCtr = 1 To UBound(FundPerfArray)
link = PathMod.FirstPath & "Company Folders\" &
FundPerfArray(iCtr).strTicker & "_" & FundPerfArray(iCtr).strFund_Name &
".Doc"

FollowHyperlink (link) ' this works if the file is present,

but
what if it is not

Set oWordDocSource = oWord.ActiveDocument
oWordDocSource.Activate
oWordDocSource.Bookmarks(1).Select
oWord.Selection.WholeStory
oWord.Selection.Copy
oWordDocTarget.Activate
oWord.Selection.Paste
oWordDocSource.Close
Set oWordDocSource = Nothing
Next iCtr
What can I do to test if the FollowHyperlink(link) is successful? I

assume
that if the test failed the resolution would be "Exit For" ?

Thanks


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.