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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel File Attributes

Status
Not open for further replies.

matt4305

IS-IT--Management
Jun 27, 2005
5
0
0
US
I have an application that loads a dataset from an Excel document. For the dataadpater I use
Code:
Dim odaExcel As New OleDbDataAdapter("SELECT * FROM [Sheet1$]", conn)
I would like to get the actual value of Sheet1 before I pull the dataset. Is their a way to get the value by opening the document?(I know how to open the document I just cant find how to return the sheet name) Thanks.

Matt McCartney
 
xlApp.ActiveWorkbook.Sheets(1).Name

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks it worked well
Code:
'Excel App
Dim excelApp As New Excel.Application 
' you dont want to see it
excelApp.Visible = False 
'Open File
original = excelApp.Workbooks.Open(FileName) 

WorksheetName = CStr(excelApp.ActiveWorkbook.Sheets(1).Name())
'close the workbook
'The entire excel app should be closed normally but I was using it further in the application so i just close the workbook
original.Close()
Matt
 
I was wondering how I could set up the file filer to only show Excel documents. Nothing I have tried has worked.
 
If I understand you correctly then:

Code:
Application.FileDialog(msoFileDialogOpen).Filters.Add "All Microsoft Excel Files", "*.xls"

Application.Dialogs(xlDialogOpen).Show

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Thanks as soon as you posted this worked for me.
Code:
With ofdExcel
            .Title = "Please Choose File"
            .Filter = "Excel files (*.xls)|*.xls|All files (*.*)|*.*"
            .FilterIndex = 1
        End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top