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

How to export a hyperlink field from Access to Excel - VBA

Does anyone know how to export a table with a hyperlink field from MS Access to Excel (using VBA), while the hyperlinks still clickable?

Thanks

MM
Dec 6 '07 #1
8 16730
JustJim
407 Expert 256MB
Does anyone know how to export a table with a hyperlink field from MS Access to Excel (using VBA), while the hyperlinks still clickable?

Thanks

MM
I think that you would have to have code in the export subroutine to open the workbook you just created with the export (transferspreadsheet method) to then format the column or range as a hyperlink. Sadly I don't know enough of Excel's flavour of VBA to tell you how to do this. Someone here will though. Hang in there, I may be able to alert someone.

Jim
Dec 7 '07 #2
Nathan H
104 100+
Does anyone know how to export a table with a hyperlink field from MS Access to Excel (using VBA), while the hyperlinks still clickable?

Thanks

MM

If the field's data type in the table is set to hyperlink, then it should be rather easy:

DoCmd.OutputTo acOutputTable, "Table1"

This works on Access 2003 to Excel 2003.
Dec 7 '07 #3
NeoPa
32,556 Expert Mod 16PB
I don't know what special export features may be available for this, but there is a short procedure that can convert a text link to a hyperlink. Displayable text is an optional extra parameter.
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Public Sub HyperConv(ranCell As Range, Optional ByVal strText As String = "")
  4.   If Left(ranCell, 7) <> "http://" Then
  5.     Call MsgBox("Invalid cell reference", vbCritical Or vbOKOnly, "HyperConv")
  6.     Exit Sub
  7.   End If
  8.   If strText = "" Then strText = ranCell
  9.   Call ActiveSheet.Hyperlinks.Add(Anchor:=ranCell, _
  10.                                   Address:=ranCell, _
  11.                                   TextToDisplay:=strText)
  12. End Sub
Dec 9 '07 #4
NeoPa
32,556 Expert Mod 16PB
Of course, if you wanted to run something against an imported (exported) sheet, then something like the following may work better :
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Public Sub HyperConv()
  4.   Dim lngRow As Long
  5.   Dim intCol As Integer
  6.   Dim ranCell As Range
  7.  
  8.   For lngRow = 1 To ActiveCell.SpecialCells(xlLastCell).Row
  9.     For intCol = 1 To ActiveCell.SpecialCells(xlLastCell).Column
  10.       Set ranCell = Cells(lngRow, intCol)
  11.       If Left(ranCell, 7) = "http://" Then
  12.         Call ActiveSheet.Hyperlinks.Add(Anchor:=ranCell, _
  13.                                         Address:=ranCell, _
  14.                                         TextToDisplay:=ranCell)
  15.       End If
  16.     Next intCol
  17.   Next lngRow
  18. End Sub
Dec 9 '07 #5
If the field's data type in the table is set to hyperlink, then it should be rather easy:

DoCmd.OutputTo acOutputTable, "Table1"

This works on Access 2003 to Excel 2003.
Thanks, Nathan, I'll try it and let you know the outcome.

MM
Dec 11 '07 #6
Of course, if you wanted to run something against an imported (exported) sheet, then something like the following may work better :
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Public Sub HyperConv()
  4.   Dim lngRow As Long
  5.   Dim intCol As Integer
  6.   Dim ranCell As Range
  7.  
  8.   For lngRow = 1 To ActiveCell.SpecialCells(xlLastCell).Row
  9.     For intCol = 1 To ActiveCell.SpecialCells(xlLastCell).Column
  10.       Set ranCell = Cells(lngRow, intCol)
  11.       If Left(ranCell, 7) = "http://" Then
  12.         Call ActiveSheet.Hyperlinks.Add(Anchor:=ranCell, _
  13.                                         Address:=ranCell, _
  14.                                         TextToDisplay:=ranCell)
  15.       End If
  16.     Next intCol
  17.   Next lngRow
  18. End Sub

Thanks NeoPa, I'll try it and let you know the outcome. MM
Dec 11 '07 #7
NeoPa
32,556 Expert Mod 16PB
Thanks NeoPa, I'll try it and let you know the outcome. MM
Please do.
Welcome to theScripts!
Dec 11 '07 #8
Please do.
Welcome to theScripts!
Thanks everyone, it works.

MM
Dec 12 '07 #9

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

Similar topics

4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
14
by: bonehead | last post by:
Greetings, I'm using the DoCmd.TransferText method to export the results of a MS Access query to a csv file. The csv will then be used to load an Oracle table. In other systems such as TOAD...
4
by: paul.chae | last post by:
I have a table in Access with about 3000 records. There are ~60 unique values in the ID field for the 3000 records. What I would like to do is automatically generate multiple Excel worksheets...
5
BBM
by: BBM | last post by:
I have an Access database of documents, with hyperlinks to PDFs. Sometimes I need to reference a document for which I don't yet have a PDF, so I type the name of the document into the hyperlink field...
1
by: smaczylo | last post by:
Hello, I've recently been asked to work with Microsoft Access, and while I feel quite comfortable with Excel, I'm at a complete loss with databases. If someone could help me with this issue I'm...
1
by: CoolFactor | last post by:
MY CODE IS NEAR THE BOTTOM I want to export this Access query into Excel using a command button on an Access form in the following way I describe below. Below you will find the simple query I am...
1
by: =?Utf-8?B?Ym9iYnk=?= | last post by:
I have a Grid View and I want to expoet into Excel. I am using a hyperlink to export the GridView intop Excel. But when I click on link it just shows me java script. It doesn't open Excel...
0
by: Simon | last post by:
Dear reader, How to export a hyperlink field from Access to Excel, so it is also working in Excel. In Excel you have for the Hyperlink to parts: a.. Text To Display
1
by: mei2523 | last post by:
I've got a query that contains a field called "URL", that field is a hyperlink field. I've got these super long hyperlinks in this field for different records, and for some reason, when I export...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.