Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Windows.Activate

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Windows.Activate

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 46
Default Windows.Activate

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 69
Default Windows.Activate

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
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
Windows().activate generating obj reqd msg why? Chet Excel Programming 2 July 26th 06 09:47 PM
Improve 'Windows(workbook.xls).Activate" statement Hank[_6_] Excel Programming 1 May 2nd 06 02:57 PM
I have no idea why this is giving me a error: Windows(dataFile).Activate madlinux Excel Programming 1 April 19th 05 07:39 AM
Reference to a variable in windows(???).Activate John Baker Excel Programming 7 July 13th 04 02:04 PM
using array with Windows().activate NikkoW Excel Programming 1 May 4th 04 03:15 AM


All times are GMT +1. The time now is 01:17 AM.

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

About Us

"It's about Microsoft Excel"