Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object (excel sheet) in a form!How to open on double click? 2

Status
Not open for further replies.

muras

Technical User
Mar 28, 2007
18
PT
Hi!
I´ve inserted an excel sheet as an object on a form but dont know how to open it on double click, need some simple vba code I supose. Can anyone help?

Thanks very much
 
Hi
Lets see, you want to open an excel sheet to be able to work from a form on access, or considering import that sheet to a table the specific records?
I suggest that you explain waht realy want to do, and mention version of access and if is an OLE object type?

Just trying to help!







Make your life an example for a better world.
 
Hi lmarc, thks for quick reply
well I´m a newbie in access and in vba,
I´m making an excel sheet with 5 pages incluing information.
I have a form in access with 2 tab pages. What I wanted to do was in the 2nd page of the tab access form make a Button that when double clicked opened the excel sheet.Not importing from excel.
I´ve made that inserting the excel sheet as object and put it as icon but when I double clicked nothing happens, as I need to put some vba code

Hope you can help
Thanks
 
You might take a look at the FollowHyperlink method.


Randy
 
Hi muras
So let see. You converted to display like a icon and want to dblclick to open it? From the icon or in the button?

In property sheet of the icon go to Data an enable it! Then in form view try dblclick and see if is this do you want.


Make your life an example for a better world.
 
Hi lmar,
That was it, I´ve just had to go to icon Data field and enable it!
Thanks ;)
 
If you wanna open by the button, insert this code on dbclick event of the button.

- Change all named (cmdButton) to your named button.
- Change "C:\...\yourfileroot.xls " to your root file.
- You can choose to open in the desired sheet to! In the code where says "Your sheet".
- And make reference to "Microsoft Excel 12.0 Object Library" in Visual basic editor at Tools - References.

Code:
Private Sub cmdButton_DblClick(Cancel As Integer)
On Error GoTo Err_cmdButton_DblClick

'Dimension the Variables
Dim xlApp As Excel.Application
Dim xlWkbk As Excel.Workbook
Dim xlSht As Excel.Worksheet

'Set the application
Set xlApp = New Excel.Application

'Make the Application Visible
xlApp.Visible = True

'Set the workbook and the filepath 'Change "C:\...\yourfileroot.xl" to your own filepath and Workbook name
Set xlWkbk = xlApp.Workbooks.Open("C:\...\yourfileroot.xls ")

'Set the worksheet that you want the workbook to open on
xlApp.Sheets("Your sheet").Select

'Turn everything off otherwise yo will have problems with your spreadsheet
Set xlApp = Nothing
Set xlWkbk = Nothing
Set xlSht = Nothing

Exit_cmdButton_DblClick:
Exit Sub

Err_cmdButton_DblClick:
MsgBox Err.Description
Resume Exit_cmdButton_DblClick

End Sub

Hope this helps.

Make your life an example for a better world.
 
Awesome lmarc!
I will try this later, it seems a great option to

Thanks for the help ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top