Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Opening another workbook and then closing it.

Hi there,

I am trying to get my code to open a workbook, then update the links and
then close the workbook again. It is working okay until I get to the line
"Windows("http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls").Activate" in the code.

It is giving me the message Run-time error '9': Subscript out of range

I have added the code below and put the troublesome line in brackets. Extra
info - the % in the filename in the initial bit where I open the file are
because it is on sharepoint and replaces spaces with %

Could anyone help with this?

Private Sub Workbook_Open()
MsgBox "Click on the statement to provide assurance on the IS controls in
place", vbInformation
Workbooks.Open Filename:= _

"http://knet/sites/fapas/risk/InformationSecurity/IS%20Documents/Plan/Statement%20of%20Applicability.xls"
Windows("IS register new one!.xls").Activate
Workbooks("IS Register new one!.xls").Activate
ActiveWorkbook.UpdateLink Name:= _
"http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls" _
, Type:=xlExcelLinks
((((Windows("http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls").Activate))))
ActiveWorkbook.Close
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Opening another workbook and then closing it.

Pasty,
Give yourself a variable to work with

Dim WS as Workbook
Set WS = Workbooks.Open
Filename:="http://knet/sites/fapas/risk/InformationSecurity/IS%20Documents/P
lan/Statement%20of%20Applicability.xls"
With WS
.UpdateLinks...etc
.Close
End with

NickHK

"Pasty" wrote in message
...
Hi there,

I am trying to get my code to open a workbook, then update the links and
then close the workbook again. It is working okay until I get to the line
"Windows("http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls").Activate" in the code.

It is giving me the message Run-time error '9': Subscript out of range

I have added the code below and put the troublesome line in brackets.

Extra
info - the % in the filename in the initial bit where I open the file are
because it is on sharepoint and replaces spaces with %

Could anyone help with this?

Private Sub Workbook_Open()
MsgBox "Click on the statement to provide assurance on the IS controls

in
place", vbInformation
Workbooks.Open Filename:= _


"http://knet/sites/fapas/risk/InformationSecurity/IS%20Documents/Plan/Statem
ent%20of%20Applicability.xls"
Windows("IS register new one!.xls").Activate
Workbooks("IS Register new one!.xls").Activate
ActiveWorkbook.UpdateLink Name:= _
"http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls" _
, Type:=xlExcelLinks
((((Windows("http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls").Activate))))
ActiveWorkbook.Close
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 95
Default Opening another workbook and then closing it.

Excellent stuff - thanks for your help.

"NickHK" wrote:

Pasty,
Give yourself a variable to work with

Dim WS as Workbook
Set WS = Workbooks.Open
Filename:="http://knet/sites/fapas/risk/InformationSecurity/IS%20Documents/P
lan/Statement%20of%20Applicability.xls"
With WS
.UpdateLinks...etc
.Close
End with

NickHK

"Pasty" wrote in message
...
Hi there,

I am trying to get my code to open a workbook, then update the links and
then close the workbook again. It is working okay until I get to the line
"Windows("http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls").Activate" in the code.

It is giving me the message Run-time error '9': Subscript out of range

I have added the code below and put the troublesome line in brackets.

Extra
info - the % in the filename in the initial bit where I open the file are
because it is on sharepoint and replaces spaces with %

Could anyone help with this?

Private Sub Workbook_Open()
MsgBox "Click on the statement to provide assurance on the IS controls

in
place", vbInformation
Workbooks.Open Filename:= _


"http://knet/sites/fapas/risk/InformationSecurity/IS%20Documents/Plan/Statem
ent%20of%20Applicability.xls"
Windows("IS register new one!.xls").Activate
Workbooks("IS Register new one!.xls").Activate
ActiveWorkbook.UpdateLink Name:= _
"http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls" _
, Type:=xlExcelLinks
((((Windows("http://knet/sites/fapas/risk/InformationSecurity/IS
Documents/Plan/Statement of Applicability.xls").Activate))))
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
Slow Opening & Odd Closing ohsix New Users to Excel 1 May 20th 07 05:28 PM
Closing a workbook upon opening another Dave New Users to Excel 3 January 3rd 07 09:57 PM
Opening/Closing a lot of groupings via VBA Dirk Flakowski Excel Programming 4 December 17th 04 08:45 AM
Opening and closing workbook with VBA... Trevor[_4_] Excel Programming 1 March 4th 04 08:33 PM
closing excel after closing a workbook CWalsh[_2_] Excel Programming 3 January 21st 04 03:33 PM


All times are GMT +1. The time now is 04:30 AM.

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

About Us

"It's about Microsoft Excel"