Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
error when using variable name for workbook
I am getting an error he
Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1) which says that "Object doesn't support this property or method" Here is the code that I used: Call GetContractFileName Workbooks.Open FileName:="G:\USER\Contracts\Data_Files\All_2004_C atalog.xls" sFile = contractfilename cntNo = ContractNo Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1) Windows(sFile).Activate Sheets(cntNo).Select _____________________________________ Public Function GetContractFileName() ContractNo = InputBox("Enter the Contract Number: ", "Contract File") contractfilename = ContractNo & ".xls" End Function |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
error when using variable name for workbook
have you wrote declaration for contractfilename variable in declarations
section? that must be done to use variables between subs.. "Emma" kirjoitti: I am getting an error he Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1) which says that "Object doesn't support this property or method" Here is the code that I used: Call GetContractFileName Workbooks.Open FileName:="G:\USER\Contracts\Data_Files\All_2004_C atalog.xls" sFile = contractfilename cntNo = ContractNo Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1) Windows(sFile).Activate Sheets(cntNo).Select _____________________________________ Public Function GetContractFileName() ContractNo = InputBox("Enter the Contract Number: ", "Contract File") contractfilename = ContractNo & ".xls" End Function |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
error when using variable name for workbook
Yes actually the error was in the syntax . I had to replace Window with
workbooks. "nippetee" wrote: have you wrote declaration for contractfilename variable in declarations section? that must be done to use variables between subs.. "Emma" kirjoitti: I am getting an error he Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1) which says that "Object doesn't support this property or method" Here is the code that I used: Call GetContractFileName Workbooks.Open FileName:="G:\USER\Contracts\Data_Files\All_2004_C atalog.xls" sFile = contractfilename cntNo = ContractNo Sheets("Sheet1").Copy After:=Windows(sFile).Sheets(1) Windows(sFile).Activate Sheets(cntNo).Select _____________________________________ Public Function GetContractFileName() ContractNo = InputBox("Enter the Contract Number: ", "Contract File") contractfilename = ContractNo & ".xls" End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Runtime Error '91' Object variable or With block variable not set | Excel Discussion (Misc queries) | |||
Run-time error '91': "Object variable or With block variable not set | Excel Programming | |||
Error 91 -- Object variable or With block variable not set | Excel Programming | |||
Cells.Find error Object variable or With block variable not set | Excel Programming | |||
Error 91 - Object variable with block variable not set | Excel Programming |