Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Error 91 while trying to save a workbook

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error 91 while trying to save a workbook

What line causes the error? I don't see any saving going on.

I'd try:

workbooks("make_the_masterfile.xls").worksheets("O verallbighitters").copy

with activesheet 'the newly copied sheet
'.parent of the new worksheet is the new workbook
.parent.saveas filename:="C:\test.xls"
end with



Adam_needs_help wrote:

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Error 91 while trying to save a workbook

The last line of the code here causes an error. Once I set the variable to
the name of the workbook I save that workbook (I do it later on). My
explanation was poor, sorry.

WBforBigHit = ActiveWorkbook.Name

"Dave Peterson" wrote:

What line causes the error? I don't see any saving going on.

I'd try:

workbooks("make_the_masterfile.xls").worksheets("O verallbighitters").copy

with activesheet 'the newly copied sheet
'.parent of the new worksheet is the new workbook
.parent.saveas filename:="C:\test.xls"
end with



Adam_needs_help wrote:

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error 91 while trying to save a workbook

Did you declare wbforbighit as a string or an object/workbook?

Dim WBforBigHit as string
WBforBigHit = ActiveWorkbook.Name
or
dim WBforBigHit as workbook
set WBforBigHit = ActiveWorkbook




Adam_needs_help wrote:

The last line of the code here causes an error. Once I set the variable to
the name of the workbook I save that workbook (I do it later on). My
explanation was poor, sorry.

WBforBigHit = ActiveWorkbook.Name

"Dave Peterson" wrote:

What line causes the error? I don't see any saving going on.

I'd try:

workbooks("make_the_masterfile.xls").worksheets("O verallbighitters").copy

with activesheet 'the newly copied sheet
'.parent of the new worksheet is the new workbook
.parent.saveas filename:="C:\test.xls"
end with



Adam_needs_help wrote:

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name


--

Dave Peterson


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Error 91 while trying to save a workbook

as a workbook, under Public variables

"Dave Peterson" wrote:

Did you declare wbforbighit as a string or an object/workbook?

Dim WBforBigHit as string
WBforBigHit = ActiveWorkbook.Name
or
dim WBforBigHit as workbook
set WBforBigHit = ActiveWorkbook




Adam_needs_help wrote:

The last line of the code here causes an error. Once I set the variable to
the name of the workbook I save that workbook (I do it later on). My
explanation was poor, sorry.

WBforBigHit = ActiveWorkbook.Name

"Dave Peterson" wrote:

What line causes the error? I don't see any saving going on.

I'd try:

workbooks("make_the_masterfile.xls").worksheets("O verallbighitters").copy

with activesheet 'the newly copied sheet
'.parent of the new worksheet is the new workbook
.parent.saveas filename:="C:\test.xls"
end with



Adam_needs_help wrote:

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name

--

Dave Peterson


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Error 91 while trying to save a workbook

Then you have to use the "Set" command.

And the only way you rename a workbook is by saving it with a new name.

Adam_needs_help wrote:

as a workbook, under Public variables

"Dave Peterson" wrote:

Did you declare wbforbighit as a string or an object/workbook?

Dim WBforBigHit as string
WBforBigHit = ActiveWorkbook.Name
or
dim WBforBigHit as workbook
set WBforBigHit = ActiveWorkbook




Adam_needs_help wrote:

The last line of the code here causes an error. Once I set the variable to
the name of the workbook I save that workbook (I do it later on). My
explanation was poor, sorry.

WBforBigHit = ActiveWorkbook.Name

"Dave Peterson" wrote:

What line causes the error? I don't see any saving going on.

I'd try:

workbooks("make_the_masterfile.xls").worksheets("O verallbighitters").copy

with activesheet 'the newly copied sheet
'.parent of the new worksheet is the new workbook
.parent.saveas filename:="C:\test.xls"
end with



Adam_needs_help wrote:

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Error 91 while trying to save a workbook

That worked, thanks. Not sure why the other macros thought my variable was a
string, but that's why they were working. I decided the string way was
easier than the workbook way. Thanks for your help.

"Dave Peterson" wrote:

Then you have to use the "Set" command.

And the only way you rename a workbook is by saving it with a new name.

Adam_needs_help wrote:

as a workbook, under Public variables

"Dave Peterson" wrote:

Did you declare wbforbighit as a string or an object/workbook?

Dim WBforBigHit as string
WBforBigHit = ActiveWorkbook.Name
or
dim WBforBigHit as workbook
set WBforBigHit = ActiveWorkbook




Adam_needs_help wrote:

The last line of the code here causes an error. Once I set the variable to
the name of the workbook I save that workbook (I do it later on). My
explanation was poor, sorry.

WBforBigHit = ActiveWorkbook.Name

"Dave Peterson" wrote:

What line causes the error? I don't see any saving going on.

I'd try:

workbooks("make_the_masterfile.xls").worksheets("O verallbighitters").copy

with activesheet 'the newly copied sheet
'.parent of the new worksheet is the new workbook
.parent.saveas filename:="C:\test.xls"
end with



Adam_needs_help wrote:

Here is my code, any idea why I ma getting error 91? I use the same basic
code elsewhere and it works. I think there may be an error in which workbook
is active. I am trying to save the workbook I just copied a sheet into.

Windows("Make_The_MasterFile.xls").Activate 'not trying to save this workbook
Sheets("OverallBigHitters").Activate
ActiveSheet.Select
ActiveSheet.Copy 'trying to save this one
WBforBigHit = ActiveWorkbook.Name

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson

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
Save Copies of Workbook with Before Save Event RyanH Excel Programming 1 October 27th 08 03:13 PM
error when I save workbook to network server in Excel 2003 khaled Excel Programming 1 June 15th 05 01:50 PM
Error in VBA code to save workbook djchristie Excel Programming 0 April 29th 04 03:26 PM
Error in VBA code to save workbook pikus Excel Programming 1 April 29th 04 03:21 PM
What commands do you use to name a workbook, save a workbook,open a workbook Steven R. Berke Excel Programming 1 July 24th 03 11:37 PM


All times are GMT +1. The time now is 04:13 PM.

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"