Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
comman button macro can't open worksheet
I recorded a macro where i select a range for copy then open a spcifi
file go to sheet2 and paste. i copy this code to a button macro, but when i tried to run and clic the button it a run-time error 1004: "Method openof object Workbook failed " the code is as follow under sheet1 (code): Sub CommandButton1_Click() Range("D2:H51").Select Selection.copy Workbooks.Open Filename:="Z:\My documents\myfile.xls" Sheets("Sheet2").Select Range("A10").Activate ActiveSheet.Paste End Su -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
comman button macro can't open worksheet
The problem here is where the macro is stored. It needs to be in a module, not in the sheet's code. Open the Visual Basic Editor and from the Insert menu, select Module. Cut and paste the macro into the module. Assign the macro to the button again. HTH Helen -----Original Message----- I recorded a macro where i select a range for copy then open a spcific file go to sheet2 and paste. i copy this code to a button macro, but when i tried to run and click the button it a run-time error 1004: "Method openof object Workbooks failed " the code is as follow under sheet1 (code): Sub CommandButton1_Click() Range("D2:H51").Select Selection.copy Workbooks.Open Filename:="Z:\My documents\myfile.xls" Sheets("Sheet2").Select Range("A10").Activate ActiveSheet.Paste End Sub --- Message posted from http://www.ExcelForum.com/ . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Comman Button | New Users to Excel | |||
Comman Button to Save Worksheet as Workbook | Excel Discussion (Misc queries) | |||
Auto filter through the Comman Button | Excel Worksheet Functions | |||
Easy one- Comman button close | Excel Programming | |||
Comman Button to open another application | Excel Programming |