VBA code to open file?

P

pgoodale

Does anyone know the line of code to open a file? I have created a macro
and am programming in VBA. All I need is the code which opens up files.
Any help is really appreciated.
 
T

Tomek

If You want to open an excel file use this:
Workbooks.Open file_name

text file in Excel:
Workbooks.OpenText file_name
for example:
Workbooks.OpenText filename:="DATA.TXT", _
dataType:=xlDelimited, tab:=True


if it is a text file and You want to read from it:
Open file_name For Input As #1

write to a file
Open file_name For Output As #1

Read the online help for open method to get more info
 
L

Leo Elbertse

You simply want to open a workbook?

Workbooks.Open "path"

or something completely different, like a word file?

Sub StartWinWord()
Dim RetVal
RetVal = Shell("C:\Program Files\Microsoft _
Office\Office10\WinWord.exe c:\boot.ini", 1)

End Sub
 
D

Don Guillett

You could have posted your code for comments and suggestions. Or, you could
have looked in vba HELP index for OPEN
We help those who help themselves.
 
Top