Solved

How to open up Excel Workbook from a button click selection

Posted on 2011-09-30
6
245 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

18 Experts available now in Live!

Get 1:1 Help Now