By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

open a file from an access hyperlink filed

P: 1
Hi,

Looking for some help....I have an access database with a hyperlink field called field1. I have a vb (vb6) form called form2 which allows the user to view records in the database 1 at a time. I have a textbox (text1) with a name, a textbox (text2) with an initial. While viewing the record I want the user to be able to click on a command button which will open an excel spreadsheet on my c:\temp that is titled the same as text1 and text2 combined (ie. c:\temp\name_initial.xls). Each record has its own spreadsheet which is named according to the text1 and text2 for each record. I have not been able to figure out how to do this. I am new with this so any help will be greatly appreciated.

Thanks
Laddie
Apr 18 '08 #1
Share this Question
Share on Google+
1 Reply


jeffstl
Expert 100+
P: 432
Hi,

Looking for some help....I have an access database with a hyperlink field called field1. I have a vb (vb6) form called form2 which allows the user to view records in the database 1 at a time. I have a textbox (text1) with a name, a textbox (text2) with an initial. While viewing the record I want the user to be able to click on a command button which will open an excel spreadsheet on my c:\temp that is titled the same as text1 and text2 combined (ie. c:\temp\name_initial.xls). Each record has its own spreadsheet which is named according to the text1 and text2 for each record. I have not been able to figure out how to do this. I am new with this so any help will be greatly appreciated.

Thanks
Laddie
http://support.microsoft.com/kb/247412


Expand|Select|Wrap|Line Numbers
  1.    Dim oExcel As Object
  2.    Dim oBook As Object
  3.    Dim oSheet As Object
  4.  
  5.    'Start a new workbook in Excel
  6.    Set oExcel = CreateObject("Excel.Application")
  7.    Set oBook = oExcel.Workbooks.Add
  8.  
  9.  
  10.    'Add data to cells of the first worksheet in the new workbook
  11.    Set oSheet = oBook.Worksheets(1)
  12.    oSheet.Range("A1").Value = "Last Name"
  13.    oSheet.Range("B1").Value = "First Name"
  14.    oSheet.Range("A1:B1").Font.Bold = True
  15.    oSheet.Range("A2").Value = "Doe"
  16.    oSheet.Range("B2").Value = "John"
  17.  
  18.    'Save the Workbook and Quit Excel
  19.    oBook.SaveAs "C:\Book1.xls"
  20.    oExcel.Quit
  21.  
That is the code for doing it in VB6...

If you are using Access, I suggest using thier button wizard for opening excel, and then modifying the code from there, or take specific issues you have after that to the Access forum as they would probably know better. Surprisingly as you probably discovered VBA is very different from VB6.

Good Luck.
Apr 23 '08 #2

Post your reply

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