Solved

How to open up Excel Workbook from a button click selection

Posted on 2011-09-30
6
250 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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