473,387 Members | 1,899 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,387 software developers and data experts.

Macro to open documents

Hi!
I am in need of some help with macros in an Access 2007 form. I have a table of document names that is linked to a list box in a form. All documents in the table have hyperlinks, so when a document name is clicked the correct document opens. This works fine. The users of the form will only have access to the form and not the table with hyperlinks, so I need for the users to be able to open any of the documents from the form. As of now, the hyperlinks do not appear in the form. I would like for users to be able to click a button beside the list box to open the document they have selected in the list box. However, I am not sure how to go about this. I hope this is clear.
Thanks in advance!
Jun 11 '09 #1
7 4122
hjozinovic
167 100+
hi there,
i was looking for the same solution today and i found this working example. It was great for me, so i hope it will help you too.
Here is the link
Jun 12 '09 #2
Thanks! I think this will work for me once I figure out how to correct some errors I keep getting.
Jun 12 '09 #3
ADezii
8,834 Expert 8TB
@bbharris
  1. Let's assume the List Box Name is lstHyperlinks.
  2. The Row Source for lstHyperlinks is a Single Field in a Table whose Data Type is Hyperlink.
  3. The MultiSelect Property of lstHyperlinks is = None.
  4. The Name of he Command Button to Navigate to the Highlighted Item in lstHyperlinks is cmdOpenHyperlink.
  5. In the Click() Event of cmdOpenHyperlink, you can write the following code which will enable Navigation to the Item currently Highlighted in lstHyperlinks in a New Window (True Argument):
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cmdOpenHyperlink_Click()
    2. On Error GoTo Err_cmdOpenHyperlink_Click
    3. Dim lst As ListBox
    4. Dim strHyperlinkAddr As String
    5.  
    6. Set lst = Me![lstHyperlinks]
    7.  
    8. If lst.ItemsSelected.Count > 0 Then
    9.   strHyperlinkAddr = HyperlinkPart(lst, acFullAddress) & "#" & _
    10.                      HyperlinkPart(lst, acFullAddress)
    11.   Application.FollowHyperlink strHyperlinkAddr, , True
    12. End If
    13.  
    14. Exit_cmdOpenHyperlink_Click:
    15.   Exit Sub
    16.  
    17. Err_cmdOpenHyperlink_Click:
    18.   MsgBox Err.Description, vbExclamation, "Error Navigating to Hyperlink"
    19.   Resume Exit_cmdOpenHyperlink_Click
    20. End Sub
Jun 12 '09 #4
Thank you so much! I have been out of town for the last week so I am just now able to get back to work on this. So far it is working, but if something comes up I will let you know. Again, thank you!
Jun 22 '09 #5
I just realized while testing the database that I left out some information that would affect this situation. I have a form that asks for the user's name. When the name is selected, a list box shows what disciplines that user falls under. The user then selects a discipline from the list box. A second list box will show what documents are associated with the discipline previously chosen. This list box is where the user selects the document to open. The code previously given works fine when testing as long as I do not select a user name or discipline because the code opens the hyperlink from the table with the hyperlinks. However, when a user name and discipline are selected, the document list is retrieved from a query and not a table. If someone could offer some advice on how to solve this I would greatly appreciate it!
Jun 30 '09 #6
ADezii
8,834 Expert 8TB
@bbharris
Now, there are many more questions to be answered, such as:
  1. The Document Name is retrieved from a List Box, so what is the name of the List Box?
  2. Can Multiple Documents be selected within the List Box, and if so Open ALL the Documents at the same time?
  3. What are the Extensions for these Documents (*.doc, *.pdf, *.rtf, etc.)?
  4. etc...
  5. etc...
  6. etc...
Jun 30 '09 #7
Thanks for responding! I think I have figured this out. It was just a matter of moving some things around a little. So far it is working, but if not I will give you some more information to help get this working. Thanks again!
Jun 30 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Carl | last post by:
Please can anyone tell me how I can create a macro to save the results of a query as an excel file? The query is called Student List and I would like to save it to "My Documents". We have had...
5
by: Mason | last post by:
I'm having some problems converting VBA for Word 2000 to code that VB.Net understands. I recorded a macro in Word to add numbering (a. b. c.) to my paragraphs. I managed to translate quite a bit...
0
by: hinew | last post by:
Hi. I have created macro for Microsoft word. However I need this to be run in visual baisc application. I need a program that ask user to select the word document which need to be processed....
0
by: Simon | last post by:
I'm using the following to open and run a macro in word wordApp.Documents.Open(MyDoc) wordApp.Run("CatgTitle") wordApp.save() The Macro goes through each item in Column A and based on the...
1
by: Bon | last post by:
Hello all I create a form with three buttons in MS Access 2000. They are Open Excel Template, Save Draft and Save Final. When I click the Open Excel Template button, the Excel template will be...
0
by: joe1977 | last post by:
my macro in Publisher changes "123" into "321" (example) but I can't be able to run it. This is how far I get throught with PHP & Publisher: <? $pub = new COM('publisher.application') or...
0
by: modularmix | last post by:
Does anyone know how to run the Excel Macro for two different spreadsheets in parallel. Here is the code that works sequentially. Workbooks.Open Filename:="C:\Documents and...
0
by: A1000ma | last post by:
I am trying to develop a C# program to fill in the blanks in a Word Form. Everything works beautifully while the program is running. I had to go in to fix some links on our Web Site a couple of...
2
by: Cele Balser | last post by:
Hello, This can't be that hard! Could someone give me the code to run a macro in my Personal.xls from my Access module? I have created a query in Access, exported it to a network drive, I can open...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.