Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Excel document not saving

From VBA, I start with an excel workbook with one worksheet. Then, I open a
second excel file (with one worksheet), edit it and bring the tab into the
original workbook. So, there are now two worksheets in the original workbook.
Then save it - this works. Then, do it again... Open a new second excel file,
edit the tab and bring it into existing workbook. Now there are 3 tabs in the
original workbook. I try to save and it gives an error "document not
saved"... using the following code:

Workbooks.Open ("\\...path\Summary.xls")
Windows("Summary.xls").Activate
Sheets("Tab1").Select
Sheets("Tab1").Move befo=Workbooks(Original).Sheets(1)
ActiveWorkbook.Save

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 324
Default Excel document not saving

If you are talking about trying to save the original workbook add this line
just below the "Save" line.
ThisWorkbook.Activate

Or instead of ActiveWorkbook.Save use This Workbook.Save.
--
Best wishes,

Jim


"Kevin" wrote:

From VBA, I start with an excel workbook with one worksheet. Then, I open a
second excel file (with one worksheet), edit it and bring the tab into the
original workbook. So, there are now two worksheets in the original workbook.
Then save it - this works. Then, do it again... Open a new second excel file,
edit the tab and bring it into existing workbook. Now there are 3 tabs in the
original workbook. I try to save and it gives an error "document not
saved"... using the following code:

Workbooks.Open ("\\...path\Summary.xls")
Windows("Summary.xls").Activate
Sheets("Tab1").Select
Sheets("Tab1").Move befo=Workbooks(Original).Sheets(1)
ActiveWorkbook.Save

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 504
Default Excel document not saving

Thanks for your help. I am getting the same problem when using the
ThisWorkbook example.

Something I neglected to mention before. The VBA is attached to an Access
database. The subroutine is not attached to the excel file which I am trying
to save.

Restating the process with further detail... Using Access VBA, the excel
application is created. Then, the initial excel file is created and saved.
Then a second, pre-exising file is opened (within the same application) that
contains a single worsheet. This worksheet is then moved to the inital file
and the initial file is resaved. Then another pre-existing file is opened and
moved into the initial file. The save doesn't work the second time through.

Thanks,
Kevin


"Jim Jackson" wrote:

If you are talking about trying to save the original workbook add this line
just below the "Save" line.
ThisWorkbook.Activate

Or instead of ActiveWorkbook.Save use This Workbook.Save.
--
Best wishes,

Jim


"Kevin" wrote:

From VBA, I start with an excel workbook with one worksheet. Then, I open a
second excel file (with one worksheet), edit it and bring the tab into the
original workbook. So, there are now two worksheets in the original workbook.
Then save it - this works. Then, do it again... Open a new second excel file,
edit the tab and bring it into existing workbook. Now there are 3 tabs in the
original workbook. I try to save and it gives an error "document not
saved"... using the following code:

Workbooks.Open ("\\...path\Summary.xls")
Windows("Summary.xls").Activate
Sheets("Tab1").Select
Sheets("Tab1").Move befo=Workbooks(Original).Sheets(1)
ActiveWorkbook.Save

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Excel document not saving

Kevin,
When Automating Excel (or any app) externally, you need to be more careful.
Creating additional refereneces, to those you expect and and deal with,
becomes a problem and may prevent you from closing down the app at the end
of your code.
Thus you should always only use fully qualified refereneces to the objects
used.
Also avoid .Select/.Activate, unless it is required, which is seldom the
case. e.g.

Dim XLApp As Excel.Application
Dim XLWBSource As Excel.WorkBook
Dim XLWBDestination As Excel.WorkBook
Dim XLWS As Excel.WorkSheet

Set XLApp=New Excel.Application
Set XLWBSource=XLApp.Workbooks.Open ("\\...path\Summary.xls")
Set XLWS=XLWBSource.Worksheets(""Tab1")

Set XLWBDestination =XLApp.Workbooks.Open ("\\...path\Original.xls")

XLWS.Move befo=XLWBDestination.Sheets(1)
XLWBSource.Save

NickHK

"Kevin" wrote in message
...
Thanks for your help. I am getting the same problem when using the
ThisWorkbook example.

Something I neglected to mention before. The VBA is attached to an Access
database. The subroutine is not attached to the excel file which I am

trying
to save.

Restating the process with further detail... Using Access VBA, the excel
application is created. Then, the initial excel file is created and saved.
Then a second, pre-exising file is opened (within the same application)

that
contains a single worsheet. This worksheet is then moved to the inital

file
and the initial file is resaved. Then another pre-existing file is opened

and
moved into the initial file. The save doesn't work the second time

through.

Thanks,
Kevin


"Jim Jackson" wrote:

If you are talking about trying to save the original workbook add this

line
just below the "Save" line.
ThisWorkbook.Activate

Or instead of ActiveWorkbook.Save use This Workbook.Save.
--
Best wishes,

Jim


"Kevin" wrote:

From VBA, I start with an excel workbook with one worksheet. Then, I

open a
second excel file (with one worksheet), edit it and bring the tab into

the
original workbook. So, there are now two worksheets in the original

workbook.
Then save it - this works. Then, do it again... Open a new second

excel file,
edit the tab and bring it into existing workbook. Now there are 3 tabs

in the
original workbook. I try to save and it gives an error "document not
saved"... using the following code:

Workbooks.Open ("\\...path\Summary.xls")
Windows("Summary.xls").Activate
Sheets("Tab1").Select
Sheets("Tab1").Move befo=Workbooks(Original).Sheets(1)
ActiveWorkbook.Save



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
saving an excel document as a PDF Rich Burf Excel Discussion (Misc queries) 4 October 1st 09 01:14 PM
Saving Excel Document to PDF Brett Excel Discussion (Misc queries) 4 August 21st 07 12:45 AM
Saving Document in Excel Sam Excel Discussion (Misc queries) 6 July 11th 06 04:03 PM
Saving Excel document without macros Rui Álvares Excel Programming 2 July 19th 05 02:05 AM
Automatically Saving an Excel Document as a Web Page Danimagus Excel Discussion (Misc queries) 0 June 1st 05 06:34 PM


All times are GMT +1. The time now is 06:01 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"