Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

My Macro stops

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bobby - 23 Jan 2006 18:50 GMT
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!
Tom Ogilvy - 23 Jan 2006 19:00 GMT
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

> Hello
> This is my code...
[quoted text clipped - 22 lines]
>
> Thanks!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.