Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default My Macro stops

Hello
This is my code...

ChDir "C:\Temp"
Workbooks.OpenText Filename:="C:\Temp\myfile.txt", Origin:=xlWindows, _
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),
Array(8, _
1), Array(12, 1), Array(17, 1), Array(21, 1), Array(29, 1),
Array(38, 1), Array(46, 1), _
Array(50, 1), Array(58, 1), Array(67, 1))
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("daily.xls").Activate
Sheets("table").Select
Worksheets("table").Unprotect
Range("t2").Select
ActiveSheet.Paste

It was working fine until I added sheet protection and the
Worksheets("table").Unprotect part.

Now I get "Paste method od Worksheet class failed."
What is causing this and how do I fix it?

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default My Macro stops

Dim bk as Workbook, rng as Range
ChDir "C:\Temp"
set bk = Workbooks.OpenText( Filename:="C:\Temp\myfile.txt", _
Origin:=xlWindows, _
StartRow:=1, _
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), _
Array(8,1), Array(12, 1), Array(17, 1), _
Array(21, 1), Array(29, 1), Array(38, 1), _
Array(46, 1), Array(50, 1), Array(58, 1), _
Array(67, 1))
set rng = activesheet.Range("A1").CurrentRegion
set rng = rng.offset(1,0).Resize(rng.rows.count-1)
Windows("daily.xls").Activate
Sheets("table").Select
Worksheets("table").Unprotect
rng.copy Destination:=Range("T2")

--
Regards,
Tom Ogilvy


"Bobby" wrote in message
...
Hello
This is my code...

ChDir "C:\Temp"
Workbooks.OpenText Filename:="C:\Temp\myfile.txt", Origin:=xlWindows,

_
StartRow:=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1),
Array(8, _
1), Array(12, 1), Array(17, 1), Array(21, 1), Array(29, 1),
Array(38, 1), Array(46, 1), _
Array(50, 1), Array(58, 1), Array(67, 1))
Range("A2").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Copy
Windows("daily.xls").Activate
Sheets("table").Select
Worksheets("table").Unprotect
Range("t2").Select
ActiveSheet.Paste

It was working fine until I added sheet protection and the
Worksheets("table").Unprotect part.

Now I get "Paste method od Worksheet class failed."
What is causing this and how do I fix it?

Thanks!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro stops at random places. Jeff Excel Discussion (Misc queries) 0 May 16th 07 02:38 AM
Macro repeats and then stops Sabba Efie Excel Discussion (Misc queries) 2 August 15th 06 11:03 PM
Macro stops before beginning. y Excel Programming 7 April 12th 04 06:06 AM
macro stops midstream dvt[_2_] Excel Programming 3 February 23rd 04 03:46 PM
Fill column macro that stops DireWolf Excel Programming 2 January 1st 04 06:04 AM


All times are GMT +1. The time now is 09:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"