Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to open up Excel Workbook from a button click selection

Posted on 2011-09-30
6
Medium Priority
?
254 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

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

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 500 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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses
Course of the Month8 days, 23 hours left to enroll

876 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