Export Excel Data

J

joannele71

Hi

I am trying to write a macro to export my data in Excel as a text file. The
followings are my codes. However, the macro works only when I am running it
manually on Excel. The macro fails to run when I schedule it to run. It
stops when the Export window pop up. What should I change in my macro to
make it works?

Sub testEXPORT()

Workbooks.Open(Filename:="c:\FLATFILE.XLA").RunAutoMacros Which:= _
xlAutoOpen

Workbooks("test.xls").Activate
Sheets("sheet1").Select

Range("A6").End(xlDown).Select
ActiveCell.Offset(0, 4).Select
anchor_cell2 = ActiveCell.Address
Range("A6", anchor_cell2).Select

Application.SendKeys ("c:\test.txt~")

Application.SendKeys ("Y~")

Application.Run Macro:=Range( _
"[FLATFILE.XLA]FLATFILE!mcp01.FixedFieldExport")

End Sub


Thanks
Joanne
 

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