Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 24
Default past method error

This is my first go at vb programming with excel. I have code attached to a
pushbutton to copy a sheet in the current workbook, open an existing workbook
and pasting the copied info over the data in a sheet called "pricing". My
code is below. I am getting a run-time err '1004': Paste method of Worksheet
class failed.
It does paste the info but doesn't finish the routine.

Any help would be greatly appreciated.

Private Sub CommandButton1_Click()

Sheets("Sheet3").Select
Selection.Copy
Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
Sheets("pricing").Activate
ActiveSheet.Unprotect Password:="xxxx"
ActiveSheet.Paste
ActiveSheet.Protect Password:="xxxx"
Sheets("Glossary").Select

End Sub


--
kr
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default past method error

Give this a try...

Private Sub CommandButton1_Click()

Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
with Workbooks("Pricelist2.xls").Sheets("pricing")
.Activate
.Unprotect Password:="xxxx"
Thisworkbook.Sheets("Sheet3").Cells.Copy Desination:= .Cells
.Protect Password:="xxxx"
end with
Workbooks("Pricelist2.xls").Sheets("Glossary").Sel ect

End Sub

--
HTH...

Jim Thomlinson


"kr" wrote:

This is my first go at vb programming with excel. I have code attached to a
pushbutton to copy a sheet in the current workbook, open an existing workbook
and pasting the copied info over the data in a sheet called "pricing". My
code is below. I am getting a run-time err '1004': Paste method of Worksheet
class failed.
It does paste the info but doesn't finish the routine.

Any help would be greatly appreciated.

Private Sub CommandButton1_Click()

Sheets("Sheet3").Select
Selection.Copy
Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
Sheets("pricing").Activate
ActiveSheet.Unprotect Password:="xxxx"
ActiveSheet.Paste
ActiveSheet.Protect Password:="xxxx"
Sheets("Glossary").Select

End Sub


--
kr

  #3   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 24
Default past method error

Thanks Jim, but now I am getting "Application-defined or object-defined
error". The debugger highlights the line beginning "ThisWorkbook.Sheets
etc..."

--
kr


"Jim Thomlinson" wrote:

Give this a try...

Private Sub CommandButton1_Click()

Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
with Workbooks("Pricelist2.xls").Sheets("pricing")
.Activate
.Unprotect Password:="xxxx"
Thisworkbook.Sheets("Sheet3").Cells.Copy Desination:= .Cells
.Protect Password:="xxxx"
end with
Workbooks("Pricelist2.xls").Sheets("Glossary").Sel ect

End Sub

--
HTH...

Jim Thomlinson


"kr" wrote:

This is my first go at vb programming with excel. I have code attached to a
pushbutton to copy a sheet in the current workbook, open an existing workbook
and pasting the copied info over the data in a sheet called "pricing". My
code is below. I am getting a run-time err '1004': Paste method of Worksheet
class failed.
It does paste the info but doesn't finish the routine.

Any help would be greatly appreciated.

Private Sub CommandButton1_Click()

Sheets("Sheet3").Select
Selection.Copy
Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
Sheets("pricing").Activate
ActiveSheet.Unprotect Password:="xxxx"
ActiveSheet.Paste
ActiveSheet.Protect Password:="xxxx"
Sheets("Glossary").Select

End Sub


--
kr

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default past method error

Sorry Typo...

Desination:= .Cells
Should Be
Destination:= .Cells
--
HTH...

Jim Thomlinson


"kr" wrote:

Thanks Jim, but now I am getting "Application-defined or object-defined
error". The debugger highlights the line beginning "ThisWorkbook.Sheets
etc..."

--
kr


"Jim Thomlinson" wrote:

Give this a try...

Private Sub CommandButton1_Click()

Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
with Workbooks("Pricelist2.xls").Sheets("pricing")
.Activate
.Unprotect Password:="xxxx"
Thisworkbook.Sheets("Sheet3").Cells.Copy Desination:= .Cells
.Protect Password:="xxxx"
end with
Workbooks("Pricelist2.xls").Sheets("Glossary").Sel ect

End Sub

--
HTH...

Jim Thomlinson


"kr" wrote:

This is my first go at vb programming with excel. I have code attached to a
pushbutton to copy a sheet in the current workbook, open an existing workbook
and pasting the copied info over the data in a sheet called "pricing". My
code is below. I am getting a run-time err '1004': Paste method of Worksheet
class failed.
It does paste the info but doesn't finish the routine.

Any help would be greatly appreciated.

Private Sub CommandButton1_Click()

Sheets("Sheet3").Select
Selection.Copy
Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
Sheets("pricing").Activate
ActiveSheet.Unprotect Password:="xxxx"
ActiveSheet.Paste
ActiveSheet.Protect Password:="xxxx"
Sheets("Glossary").Select

End Sub


--
kr

  #5   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 24
Default past method error

I am good at typos also ~ note my description "Past method error" instead of
"Paste method error"

Thanks so much for your help, I was about to pull my hair out trying
different things.

--
kr


"Jim Thomlinson" wrote:

Sorry Typo...

Desination:= .Cells
Should Be
Destination:= .Cells
--
HTH...

Jim Thomlinson


"kr" wrote:

Thanks Jim, but now I am getting "Application-defined or object-defined
error". The debugger highlights the line beginning "ThisWorkbook.Sheets
etc..."

--
kr


"Jim Thomlinson" wrote:

Give this a try...

Private Sub CommandButton1_Click()

Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
with Workbooks("Pricelist2.xls").Sheets("pricing")
.Activate
.Unprotect Password:="xxxx"
Thisworkbook.Sheets("Sheet3").Cells.Copy Desination:= .Cells
.Protect Password:="xxxx"
end with
Workbooks("Pricelist2.xls").Sheets("Glossary").Sel ect

End Sub

--
HTH...

Jim Thomlinson


"kr" wrote:

This is my first go at vb programming with excel. I have code attached to a
pushbutton to copy a sheet in the current workbook, open an existing workbook
and pasting the copied info over the data in a sheet called "pricing". My
code is below. I am getting a run-time err '1004': Paste method of Worksheet
class failed.
It does paste the info but doesn't finish the routine.

Any help would be greatly appreciated.

Private Sub CommandButton1_Click()

Sheets("Sheet3").Select
Selection.Copy
Workbooks.Open Filename:="G:\PriceLists\PriceList2.xls"
Workbooks("Pricelist2.xls").Activate
Sheets("pricing").Activate
ActiveSheet.Unprotect Password:="xxxx"
ActiveSheet.Paste
ActiveSheet.Protect Password:="xxxx"
Sheets("Glossary").Select

End Sub


--
kr

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
SaveAs method error Horatio J. Bilge, Jr. Excel Discussion (Misc queries) 3 October 6th 09 09:05 PM
PasteSpecial Method Error PW11111 Excel Discussion (Misc queries) 1 December 19th 06 01:24 PM
How can i get past the overflow error? georgesmailuk Excel Programming 6 May 31st 06 01:41 AM
Error when use find method in vb6 Kay[_5_] Excel Programming 0 May 11th 06 01:02 AM
addfields method error jnewl Excel Programming 0 August 31st 05 02:13 PM


All times are GMT +1. The time now is 05:18 PM.

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

About Us

"It's about Microsoft Excel"