INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Access to Excel

Access to Excel

(OP)
I am trying to export Access data as Excel using ADO. I have tried the following two methods below. I would like the data formatting to be kept for a field in my Access database that is a field type of Hyperllink.

The top method is coming out as a text field and the bottom method comes out as a general format.

Any ideas?

Thanks.

CODE

conn.Execute "SELECT * INTO [Excel 8.0;Database=" & _
ExcelFileName & "].[Sheet1] FROM MASTER WHERE [Status] = 0", NumOfRecExp 

CODE

Set rs = conn.Execute("Master", , adCmdTable)

'Create a new workbook in Excel
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)

'Transfer the data to Excel
oSheet.Range("A1").CopyFromRecordset rs

'Save the Workbook and Quit Excel
oBook.SaveAs ExcelFileName
oExcel.Quit

'Close the connection
rs.Close 

Swi

RE: Access to Excel

(OP)
I wasn't very keen on doing it this way but:

CODE

For Each cell In oSheet.Range("AQ2:AQ" & FileCount + 1)
    If cell.Value <> "" Then
        url = cell.Value
        oSheet.Hyperlinks.Add Anchor:=cell, _
          Address:=url, TextToDisplay:=cell.Value
    End If
Next cell 

Swi

RE: Access to Excel

(OP)
Worked but now I am running into issues when this is emailed. The links work when the Excel file is in the path it was created but when moved to another folder the hyperlinks no longer work.

Swi

RE: Access to Excel

(OP)
Looks like an Excel issue.

I had to change this setting on the machine that this app was running on.

Tools, Options, General, Web Options, Files, UNcheck "Update links on save"

Swi

RE: Access to Excel

I'd code the entire application in Excel, where the query and hyperlink would occur when the workbook is opened.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close