Need code to Open a BROWSER and view an HTML file

Posted on 2014-07-28
Last Modified: 2014-07-28

I have a query that displays a column called description that includes html text.
Is there a way that I can view the code using a browser by clicking on the specific cell that I want to view?

I read an older message board posting from one user who said there is a way to do this using an OLE Object type of table cell.  I've also wondered whether I might use the hyperlink cell type.

If this is not possible, I have already written code to save a file on the disk at C:\mytempfolder\exportfile.html and can get by if I get code to open the file with a browser.

Your help is always appreciated

'm using MS Access 2000, XP Pro
Question by:pcalabria
    LVL 33

    Expert Comment

    I don't use the hyperlink data type, mostly because it isn't supported by SQL Server.  I just use a text data type and set the FormatAsHyperlink property to always.  Then in the click or dbl-click event, use the FollowHyperlink Method to open the document.  This will open whatever app is set as the Windows default for this particular file extension.  If the default doesn't work for you, you can use Shell but you will need to know what application you want to open and where it is so this method can cause issues if your users don't have consistent software and install locations.  So start with the FollowHyperlink because it relies on defaults.

    Author Comment

    Perhaps you can explain a bit further...

    I currently have a column called Description in a query that contains HTLM code.

    Is FormatAsHyperlink a property of the query?  If so, where is it and is it supported in Access 2k?

    Also, what do mean by FollowAsHyprelink method?  I've used that before to link to urls, will it work for a file on my hard drive?
    LVL 33

    Accepted Solution

    You can't do any of this in the query.  You need to open a form bound to the query because we are talking about properties of controls on a form and code that you execute in events and none of those apply to queries.

    The FollowHyperlink method works for any file type as long as it is registered with Windows so Windows knows what program is defined as the default for when you double-click on a file of that type.  So, if you double-click on a file and some app opens up the document, then FollowHyperlink will work.  If Windows asks you what program you want to use, then FollowHyperlink will not work.  To make it work, you need to create a new association.  For example, you can associate notepad with file extension = .abc.  Then if you double-click on, Notepad is launched and will try to open the specified file.  I use FollowHyperlink all the time to open documents that my users "attach" to an audit.  This method frees me from having to use Shell where I would have to know the path to the executable.  So, if I wanted to open a .doc file using Shell, I would need the path to the MSWord.exe file and that means I would also need to know the version since versions are typically loaded into different folders.

    Author Closing Comment

    Thanks!  Works great!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now