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

opening an excel file from a visual basic command button

Status
Not open for further replies.

vaughn9

Technical User
Sep 23, 2001
183
I am try to open an excel file from visual basic using code similar to code I used to open a word document.

I am getting an error saying that object does not support property

I selected the excel 9.0 object libray
declared the ExApp in General then my code reads as follows


Set ExApp = New Excel.Application
ExApp.Visible = True
ExApp.WindowState = wdWindowStateMaximize

ExApp.Documents.Open FileName:="C:\My Documents\may.xls", ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto


Could someone point out to men where I am going wrong
 
I use the Workbooks.Open method for Excel files:
[tt]
Workbooks.Open Filename:="C:\fred.xls"
[/tt]
You can get a full list of the parameters from Excel VB Help, or from Intellisense from Workbooks.Open

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Hello vaughn9,

Just to further the note of johnwm. What called in Word .Documents will be .Workbooks in Excel and .Presentations in Powerpoint etc. Hence, your .open line begins with :
[tt]ExApp.Workbooks.Open ...[/tt]
The exact calls for auguments can be read from obj viewer. You have to check it if you want to pass a full range of arguments.
Function Open(Filename As String, [UpdateLinks], [ReadOnly], [Format], [Password], [WriteResPassword], [IgnoreReadOnlyRecommended], [Origin], [Delimiter], [Editable], [Notify], [Converter], [AddToMru]) As Workbook
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top