Windows.Activate

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

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
 
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.
 
Thanks guys!!

Tom Ogilvy said:
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.
 
Back
Top