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!

You'd think copying would be easy. 1

Status
Not open for further replies.

kwill

Technical User
Aug 15, 2001
49
US
I'm trying to open a notepad file, select all, copy all, then paste all back to excel.

I'm using:

AppActivate ("stuff")
SendKeys ("^a")
SendKeys ("^c")
AppActivate ("book1")
Range("A1").Select
SendKeys ("^v")

What am I doing wrong???
 
On the other hand, 'notepad' only really addresses "text" files, so opening it to get the content seems a bit of the long way 'round the barn'. Just open the text file which you would have in notepad and read it according to the format. Or, if it is a CSV format Excel can probably 'read' it directly, so Ms. Access is un-necessary?

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Consider this.....very easy......simply record a macro and open the file delimeted to your needs.

It will look something like this.

Sub auto_Open()

Application.ScreenUpdating = False

ChDir "C:\My Excel Files\Inventory Files"
Workbooks.OpenText FileName:= _
"C:\My Excel Files\Inventory Files\REPORT_SF_DISPATCH.txt", Origin:=xlWindows _
, StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array( _
14, 1), Array(30, 1), Array(34, 9), Array(84, 1), Array(92, 9))

[C1].Select
Application.DisplayAlerts = False

ActiveWorkbook.SaveAs FileName:= _
"C:\My Excel Files\Inventory Files\REPORT_SF_DISPATCH.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False

Workbooks("REPORT_SF_DISPATCH.xls").Activate
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top