Error in macro, that opens a file!

A

aiyer

Hi all!

I've a quick question with respect to the short macro shown below.

Sub importfile()
Application.DisplayAlerts = False
MyFile = Application.GetOpenFilename("text files,*.txt")
Workbooks.OpenText FileName:=MyFile, _
Origin:=xlWindows, StartRow:=1,
DataType:=xlFixedWidth, FieldInfo:= _
Array(Array(0, 1), Array(11, 1), Array(20, 1))
ActiveWindow.WindowState = xlNormal
Sheets("MyFinal").Select
Sheets("MyFinal").Move Before:=Workbooks
("vtec.xls").Sheets(1)
End Sub


The browsed and selected *.txt file is assigned to the variabl
"MyFile".
However, I am unable to move it before the existing workbook '
tec.xls' and it is giving me error. A small error in the line:

Sheets("MyFinal").Select
Sheets("MyFinal").Move Before:=Workbooks("vtec.xls").Sheets(1)

I would appreciate any tips.
Thanks alot guys.

Regds,

Arun.
Vtec Corp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top