Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all. The code below opens a file, copies the data on a specific sheet
from the opened file, then reactivates the original workbook and pastes the data. It then goes back to the opened file and closes the file. When a co-worker runs this code, we get a subscript out of range error on the line : Windows("Salary Non").Activate When I run the code under a different logon, it works fine with no errors. Is there something that may be logon specific that would cause this code to fail for one user and not another? And is there a better way to accomplish this that may eliminate the problem, meaning different syntax or different commands? Thanks so much!! Sub Open_SN() Set model = ActiveWorkbook Workbooks.Open Filename:="\\server\folder1\folder2\folder3\Salary Non.xls" Sheets("Format").Cells.Copy model.Activate SN.Select 'Sheet name set in properties window in VBE Cells.Select ActiveSheet.Paste Windows("Salary Non").Activate Application.CutCopyMode = False ActiveWorkbook.Close End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
always use
Windows("Salary Non.xls").Activate this will work on all computers. whether it works or not without the extension is an option in folder options about displaying known file extensions. -- Regards, Tom Ogilvy "Steph" wrote: Hello all. The code below opens a file, copies the data on a specific sheet from the opened file, then reactivates the original workbook and pastes the data. It then goes back to the opened file and closes the file. When a co-worker runs this code, we get a subscript out of range error on the line : Windows("Salary Non").Activate When I run the code under a different logon, it works fine with no errors. Is there something that may be logon specific that would cause this code to fail for one user and not another? And is there a better way to accomplish this that may eliminate the problem, meaning different syntax or different commands? Thanks so much!! Sub Open_SN() Set model = ActiveWorkbook Workbooks.Open Filename:="\\server\folder1\folder2\folder3\Salary Non.xls" Sheets("Format").Cells.Copy model.Activate SN.Select 'Sheet name set in properties window in VBE Cells.Select ActiveSheet.Paste Windows("Salary Non").Activate Application.CutCopyMode = False ActiveWorkbook.Close End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks guys!!
"Tom Ogilvy" wrote in message ... always use Windows("Salary Non.xls").Activate this will work on all computers. whether it works or not without the extension is an option in folder options about displaying known file extensions. -- Regards, Tom Ogilvy "Steph" wrote: Hello all. The code below opens a file, copies the data on a specific sheet from the opened file, then reactivates the original workbook and pastes the data. It then goes back to the opened file and closes the file. When a co-worker runs this code, we get a subscript out of range error on the line : Windows("Salary Non").Activate When I run the code under a different logon, it works fine with no errors. Is there something that may be logon specific that would cause this code to fail for one user and not another? And is there a better way to accomplish this that may eliminate the problem, meaning different syntax or different commands? Thanks so much!! Sub Open_SN() Set model = ActiveWorkbook Workbooks.Open Filename:="\\server\folder1\folder2\folder3\Salary Non.xls" Sheets("Format").Cells.Copy model.Activate SN.Select 'Sheet name set in properties window in VBE Cells.Select ActiveSheet.Paste Windows("Salary Non").Activate Application.CutCopyMode = False ActiveWorkbook.Close End Sub |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try puting xls on the end:
Windows("Salary Non.xls").Activate James Steph wrote: Hello all. The code below opens a file, copies the data on a specific sheet from the opened file, then reactivates the original workbook and pastes the data. It then goes back to the opened file and closes the file. When a co-worker runs this code, we get a subscript out of range error on the line : Windows("Salary Non").Activate When I run the code under a different logon, it works fine with no errors. Is there something that may be logon specific that would cause this code to fail for one user and not another? And is there a better way to accomplish this that may eliminate the problem, meaning different syntax or different commands? Thanks so much!! Sub Open_SN() Set model = ActiveWorkbook Workbooks.Open Filename:="\\server\folder1\folder2\folder3\Salary Non.xls" Sheets("Format").Cells.Copy model.Activate SN.Select 'Sheet name set in properties window in VBE Cells.Select ActiveSheet.Paste Windows("Salary Non").Activate Application.CutCopyMode = False ActiveWorkbook.Close End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Windows().activate generating obj reqd msg why? | Excel Programming | |||
Improve 'Windows(workbook.xls).Activate" statement | Excel Programming | |||
I have no idea why this is giving me a error: Windows(dataFile).Activate | Excel Programming | |||
Reference to a variable in windows(???).Activate | Excel Programming | |||
using array with Windows().activate | Excel Programming |