Solved

How to open up Excel Workbook from a button click selection

Posted on 2011-09-30
6
246 Views
Last Modified: 2012-08-14
I have posted code below that will open up the Excel Spreadsheet however I can;t seem to figure out how to open up an individual workbook for selection.

Thanks
Private Sub btnXYZFile_Open_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXYZFile_Open.Click
        Dim XlFilePath As String
        Me.dlgOpenPartfile.InitialDirectory = _Default_Definition_FileOpen_Dir
        If Me.dlgOpenPartfile.ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
            '  Opens the target Excel File
            Dim ExcelObj As New Microsoft.Office.Interop.Excel.Application
            ExcelObj.Visible = True

        End If
    End Sub

Open in new window

0
Comment
Question by:cmdolcet
  • 3
  • 2
6 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36891844
Not sure what you mean. Do you want to open an Excel file in Excel? Use Process.Start("path of xls file")
0
 

Author Comment

by:cmdolcet
ID: 36891862
how do I get that path. I can open up a selection window in the code above the Excel Object but when I select the File in the folder the workbook doesn;t open
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36892001
The path will be Me.dlgOpenPartfile.FileName property.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:cmdolcet
ID: 36892257
How can I capture the value selected ?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 125 total points
ID: 36892319
Code Cruiser told you how to get the value. You can use it this way:

ExcelObj.WorkBooks.Open(dlgOpenPartfile.FileName)
0
 

Author Closing Comment

by:cmdolcet
ID: 36892330
opps I didn't read that carefully
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

15 Experts available now in Live!

Get 1:1 Help Now