Normal open file in VBA

I am trying to open a file, but it does not work.

Workbook.Open C:\users\me\desktop\testfile.txt

I always get the error message: Runtime error "424": object required

I just want to open the file. It is not fixed if the file is exel, txt, jpg or text file.

It should be as simple as possible.

+3
source share
3 answers

To open a word, excel, jpg, pdf or any file, simple use:

Application.FollowHyperlink "path to file name"
+6
source

First create an Excel object:

Dim xl as New Excel.Application

xl.Workbooks.Open("C:\users\me\desktop\testfile.txt")
xl.Visible = True
0
source

You are trying to open a text file in excel ..

Then use opentext

Example

Workbooks.OpenText ("C:\users\me\desktop\testfile.txt")
0
source

All Articles