473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Command to test for success of FollowHyperlink

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
2 3497
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Mr. Bungle | last post by:
I would like to send email automatically via a command button. I have accomplished this just fine through the following code: (Outlook should already be open for reliable results) Private Sub...
2
by: Colleyville Alan | last post by:
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...
8
by: zhiwei wang | last post by:
I remember that there is a function that could invoke shell command such as "rm" "cp", directly in .c file. But I could not recall its name, and I googled with nothing meaningful. I vaguely...
8
by: Charles Law | last post by:
I am implementing the command pattern in VB.NET, where the commands have been serialised. That is, I have several classes that all inherit from my base Command class, that implements ICommand...
2
by: jake_allen_no_spam | last post by:
Hi All How do you run an external windows command in Microsoft Access. I have a VBA script and I want to start internet explorer from within Access. Is there a run host command to start a...
6
by: Stinky Pete | last post by:
HI, I've been trolling through the archives of this list in order to better understand how to get Access to open Adobe Acrobat and a specific pdf file. Having never done this before, I've got a...
7
by: support | last post by:
Hi, I am trying to change the text of a Command button using the Windows API Function SetWindowText, which I have declared as follows: <DllImport("User32")_ Public Function...
1
by: AlexZh | last post by:
Hi, I'd like to stop command line build by one project build failed. To do that I've created simple AddIn (see code below), that works fine for IDE and does not work for command line. In the AddIn...
16
by: Steve | last post by:
I am working on a database that has a main menu, many sub-menus and some sub-sub-menus. They are all forms that have numerous command buttons on them to open forms and reports in the database. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.