Using Hyperlinks within Userforms

Hi all,

I have a Userform with various command buttons in place. What I'm
trying to do is allow users to be able to open various Word documents
when they click on these command buttons via the use of hyperlinks
embedded within the click event of each command button.

So if they click on one of the command buttons it opens one Word
document, and if they click another, it opens the second Word document
etc. etc.

It would be ideal to have the Userform to always remain displayed, so
the documents open in the background, and the Userform always has the
focus... then once the desired documents are all opened they can then
close the Userform if they wish.

Thanks for your help


assertec1 (9)
2/14/2006 3:26:15 AM
excel 39879 articles. 2 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 59

Hello Karen,

Hyperlinks are not avaibale to the UserForm in VBA. Since you are
launching Word documents from the command button click event, you can
use an API call to have the system open the document. Using a few more
API calls, it is easy to get the Form to stay on top of all the other
documents. Add a VBA module to your workbbok and copy the code between
the lines into it.

'Returns the Window Handle of the Active Window
Declare Function GetActiveWindow _
Lib "user32.dll" () As Long

Private Declare Function SetWindowPos _
Lib "user32.dll" _
(ByVal hWnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal X As Long, _
ByVal Y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long

Declare Function ShellExecute _
Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hWnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Sub OpenFile(ByVal File_Name As String)

Dim RetVal
RetVal = ShellExecute(0&, "open", File_Name, vbNullString,
vbNullString, 1)

End Sub

Public Sub KeepFormOnTop()

Dim hWnd As Long
Dim RetVal

Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1

hWnd = GetActiveWindow()
RetVal = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, _

End Sub

To the Command Button Click events add the following line of code:
(You must include the Directory path along with the file name)
Be sure to change the Directory and File name to what you are using.

Call OpenFile("C:\Documents and Settings\Karen\My Documents\Document

To the USerForm Activate event add this line of code:
Call KeepFormOnTop

Leith Ross

Leith Ross
Leith Ross's Profile:
View this thread:

2/14/2006 7:47:29 AM
Thanks for this Leith - it all worked fine.


assertec1 (9)
2/15/2006 4:56:15 AM

Similar Artilces:

Which function to use to open an .asc file?
Hi Im writing a vba program to take the info from an asc file into sheet2. I must use the xldelimited so the info goes into each column properly and not just everything in one column ( it uses the comma to determine the column). The intention of the program is, in sheet1, a command button is used to open a file window. The asc file is then selected bu the user, and the data is to placed into sheet2. The asc file is no longer needed. Calculations are made and shown in sheet1 using the data in sheet2. The problem is Im not sure what function to use. Im thinking this one: object.OpenAsTe...

Store.exe uses 98% CPU! Please help!
We're running Exchange 5.5 on an NT4 Server. Lately, store.exe process runs at 98% of CPU. We found a message pending in the Internet Mail Service "Incoming awaiting for conversion" queue and tried to delete it but it doesn't go away! Everytime, we delete a mailbox, the mail server hangs and we have to restart it. Clients can still send/receive mail though. Is it a way to solve this problem? Thanks in advance! The only way for us to determine the cause of this problem would be to start a performance log during the time of the problem and then create two dump fi...

publishing website to server using Publisher 2007
I was able to publish my home page with the help of my hosting company (godaddy) but can not publish any changes through the program Publisher 2007. when I hit the command "publish to the web", no box comes up asking for the user name and password to server. Please help. I don't know if I used FTP or HTTP when I uploaded the first time. Please help. That site doesn't have FrontPage extensions installed, so you must use ftp. -- ~~~~~~~~~~~~~~~~~~ Rob Giordano Microsoft MVP Expression "Louise" <> ...

How to change an entire row using conditional formating
Hi.. I am trying to make the text of an entire row go a different colour (light grey) when a specified cell is equal to a given value (in my case the letter ‘Y’) I can easily do something similar using the ‘equal to’ condition in the ‘Conditional Formatting’ functions, but this will only work on the one cell and not an entire row.. Can anyone write me the function or correct Conditional Formatting for this to work ..? Thanks in advance ..J Hi - select your row (lets say row 1) - goto the conditional format dialog - choose 'formula is' - enter something like =$A1="Y&quo...

Using the full width of an Excel chart with two Y-axes
I am trying to create a line chart in Excel 2007 with two data series, each with their own Y-axis. First, I create a simple chart by selecting the two data series, and choosing [Insert > Charts > Line] from the Ribbon. I now see the following chart in my workbook: I then continue my quest by right clicking one of the data series (lines) and choosing [Format data series > Series Options > Secondary Axis]. My chart is now looks like this: This is almost what I want. I did not expect to see the gap...

Scrolling Text Box Within Worksheet From Another
Hi! I'm creating a spreadsheet which is designed to enter updated comments against a customer account for the use by sales people - basically a poor mans CRM system! What I'd like to do is insert some sort of scrollable text screen within a worksheet that links to a raw data worksheet in the same spreadsheet. A little bit like this message box that we type in while posting a message, but pulling back information based on a specific condition like show me all the comments on customer x that have been entered previously. I'd GREATLY appreciate any advise! Nathan, I'm ...

Using debtor/Creditor enquiry window, see exact oustanding amount
When using an enquiry window for either Debtor or creditor , Client would like to instantly be able to tell their customer/creditor the amount that they have oustanding straight away - instead of going through all the trns and adding them up manually ect ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click &quo...

Using a browse button
I have attempted to use the code supplied on and as I have limited knowledge of VBA have found it a bit confusing. The Issue I have however, is that how do I link this code to a button, I have completed usual practice of using the 'on click' event in the properties but this requires the use of a sub rather than a function. Please advise. Thanks What you do is copy everything between Code Start and Code End into a new module (make sure it's not a class module nor the module associated with a form. Also make sure when you save it th...

Running Dos command using shellExecute
I am trying to run dos command DEL /f /s /q c:\\dirname\\* using ShellExecute API but command does not run and gives the error code 2 i.e file not found. IF i run the same command using system call then it works. Can anyone tell me how to use shellexecute to run dos command. I am using in following way ShellExecute(NULL, "open", "DEL /f /s /q c:\\check\\*", NULL, NULL, SW_HIDE); thanks manoj <> wrote in message >I am trying to run dos command DEL /f /s /q c:\\dirname...

use shared workbooks on Web servers
Is there a way to share workbooks on webserver? I need a way where multiple users can update the workbook online. Please let me know if any one has a clue. Thanks Geetha Hi, Gkrish; This is from Excel online help: (Features that are unavailable in shared workbooks): "You cannot use shared workbooks on Web servers." -IanRoy "Gkrish" wrote: > Is there a way to share workbooks on webserver? I need a way where multiple > users can update the workbook online. > > Please let me know if any one has a clue. > > Thanks > Geetha ...

Custom border using art
I have an image that publisher lets me use as a custom border. What I would like is for the image to rotate 90 degrees on the vertical. Is this possible? I do not want to have to line up multiple copies of the image in order to acheive this. I have Publisher 2003, small business ed., running on XP. Create the border from scratch... Insert your image, resize, rotate 90 degrees, copy/paste until you have enough. You can use the Distribute tool in the arrange menu for the spacing. Group, copy/paste, rotate again for the other side. -- Mary Sauer "A_Ross"...

How to save Publisher 2003 files to Web using older Publisher for.
In the Office 2000 version of Publisher, I was able to save files in a Web format that included separate .html and graphic files. Now, with Publisher 2003, the "Save As Web" function creates file outputs that are no longer compatible with Adobe Acrobat. Is there a way to save Publisher files inthis older format for the Web? Use File, Publish.... to get the "filtered" html don't use File, Save as..., web David Bartosik - [MSFT MVP] "Steve D'Erasmo" <Steve D'Erasmo@discussions.micros...

select a record using datasheet view, then use form view to edit
Here's what I'm trying to do: I've created a form using autoform which creates a form with the parent table info on top and the child table below in datasheet view which is what I want because I want the user to be able to see all the related records easily. How can I open the child record in form view from the datasheet view? thanks for your input ...

Temp files appearing on the recently used file list
we've just upgraded to Office-XP and now notice that spreadsheets launched from e-mail etc that are just opened and not saved are then appearing in the recently used file list at the bottom of the file menu. Is this a bug or a new MS 'feature' Is there a way of stopping this, it does not appear to happen on Word and didnit happen on Office-2k Thanks in advance Hi Julie sounds like your email client stores the file in your temp file end Excel opens it from there. So from Excel's point of view it's o.k. that it appears in the most recent file list :-) -- Regards Frank K...

Activating a Cell after using a filter
I am trying to retrieve the contents of a cell (as a string) returned after applying a filter. The filter acts on the 1st column of the worksheet and gradually reduces the filter results and the number of rows returned as text is entered into my form. untill I am left with only 1 row. The reference of this row is variable as the entire list is alphabetical and the results are narrowed the more keypresses I make. I need to be able to set a cell as active so I can apply an edit to the row using the offset command, once the filter has returned row I need. Any thoughts would be appreciated. Rgds ...

Using Linked forms/subforms to update data on SQL Server
Hello, I designed a database in Access and then transferred the data to SQL Server. The linked form/subform that worked when the data resided within the Access database is not functioning properly. Here's the setup: tblContacts has Primary Key ContactID (formerly Autonumber, now an identity field in SQL Server) tblAddress contains Contact ID and also Primary Key CARID (also now an identity field in SQL Server). Using SQL Server Enterprise Manager Diagram, I set up a one to many relationship between tblContact and tblAddress with cascade updates/deletes (one person can have multipl...

Simplfied version of my code is below. I am trying to iterate through all the subfolders searching for .MDB files which I will then open and get the value of a column. In setting up the code to recursively go through the folders, I am getting an "Invalid use of property" compile error on the "fc2 = ..." statement below. I fail to see the difference between the "fc = f.SubFolders" and "fc2 = fold1.SubFolders" statements. The fc= statement works and the other gets an error. I am using Access 2002 (3rd party product creates the MDBs). ...

form within a form
I have Office Professional 2007 (Vista) . I have a simple data base with about 500+ names, addresses, etc. Many of the names have unusual spelling. I would like to make some type of form on my basic form that would allow me to enter the first letter of a last name and have all names starting with that letter to show up. I have a parameter query and made a parameter sub form, and it works fine by itself but if I try to put it in the design when I then try to save it the subform wants to work right then and does but when I close the design view the parameter subform is just bl...

Callout use: Applying callouts to 3,000 cells similar to iPhone sms.
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Hey, <br><br>I've got an excel sheet with my sms messages between my girlfriend and I. Theres about 3,000 rows of texts in two columns (each column has one person's side of the conversation). <br><br>I'm would like to format each cell with a &quot;callout&quot; (the cartoonish speech bubble) similar to messaging format used on an iPhone so that I could get a small booklet of our conversations printed out. <br><br>Is there any quick way to format all of thes...

Using GP for Email Campaigns
Anyone successfully using the Customers (Active and Inactive) piece of GP for successfully tracking email campaigns? I would assume one would need to use extender heavily. OR Am I just better off using excel offline. Also, plan to use Constant Contact to deliver the messages. Thanks Tom Flick ...

Licensing question using front end / back end ex2k3
This is a multi-part message in MIME format. ------=_NextPart_000_001E_01C43E97.760B1C80 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable If I want to setup a ex2k3 server in a front end and back end = configuration can I run that on one license since I'm using half of the = software on one server and the other half on another? Or do I need to = purchase a separate exchange license for the front end server? Thanks. ------=_NextPart_000_001E_01C43E97.760B1C80 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-E...

Please provide feedback about Workgroup/Untrusted domain production server protection using DPM 2010 RC
Please provide feedback about Workgroup/Untrusted domain production server protection using DPM 2010 RC. This feature supports backup of machines within your intranet which includes: 1. Workgroup machines 2. Machines in untrusted domains within your intranet Supported Scenarios .. Files .. System state .. SQL Server .. Exchange Server .. Hyper-V .. Small Business Server Unsupported Scenarios: .. Clustered servers (except for Exchange Server 2010) .. Mirrored servers .. Microsoft SharePoint .. Laptop .. System protection (BMR) .....

Best book for creating GUI using Visual C++ (VS 2003)
Hi all, First of all sorry for the cross post. I was not sure which ng would be most appropriate. I need a book that gives guidelines on good GUI design (preferably, comes with a few template GUIs one can extend). There seems to be so many books out there, I would be very grateful to hear from any experienced GUI designer out there - who can recommend a book for designing GUIs. A bit of background of my self. I am a C/C++ developer, but have some basic GUI design experience using VBs Form Designer. I have a little experience of MFC but I'm hoping to generate a lot of the boiler p...

Creating print sections within a worksheet
I'd like to have unique headers for parts of a worksheet when I print the data. Is it possible to create sections within a worksheet? Otherwise, if I have each set of unique data in separate tabs, eahc tab having it's unique header text, is there a way to create a pdf that is the combination of several tabs? My fallback would be to copy pieces of the data from Excel and paste them into sections of a Word document. Thanks, Jeff Jeff - See "Custom View" in Excel's Help. - Mike Middleton Decision Analysis Add-ins for Excel "M...

What function would I use? #2
Thanks for the suggestion it did work really well, but I think I'm dealing with a little too much data for it. This is an example of what I'm trying to do. Product 1 -------------------------------------------------------- Customer name | accesorie a |accesorie b| accessorie c | -------------------------------------------------------- Bob | yes | | | -------------------------------------------------------- Mary | | yes | | ------------------------------------------...