Solved

Method 'Save' of object '_Workbook' failed

Posted on 2008-06-09
11
1,476 Views
Last Modified: 2011-10-19
I am creating an Excel spreadsheet from Access using VBA (Office 2002).  After I create and modify the spreadsheet I save it and get the error:

Error -2147417851
Method "Save' of object '_Workbook' failed

(edited code snippet below)
Dim objXLApp As Excel.Application
Dim objXLBook As Excel.Workbook
Dim objQuerySheet As Excel.Worksheet
Dim objResultsSheet As Excel.Worksheet
Dim objXLRange As Excel.Range
   
         DoCmd.OutputTo acOutputReport, "rptStockGoals", acFormatXLS, strPath, -1
        Set objXLBook = GetObject(strPath)
        Set objXLApp = objXLBook.Parent
        Set objQuerySheet = objXLBook.Worksheets("rptStockGoals")
        objXLApp.Visible = True
        objXLBook.Windows(1).Visible = True
<modify the spreadsheet here>
~Error occurs when the next line is executed.
        objXLBook.Save

So I create the spreadsheet from access/vba with no problem.  I open it and modify it but when I go to save it my error occurs.

This only happens for two users and only when they are logged onto their PC's.  If I log on to their PC I do not get the error.  If they log on to another PC they do not get the error.  For one of the users this code has worked until a few weeks ago.

When the error occurs a file is created (attached) in the same directory where I saved the spreadsheet.  It is named something different each time , eg. 038C3100 with no extension.

I can close the spreadsheet after the error occurs but Excel itself hangs.

If you need any further info please let me know.

Thanks


038C3100
0
Comment
Question by:bshort1023
  • 5
  • 2
  • 2
  • +1
11 Comments
 
LVL 21

Expert Comment

by:oleggold
ID: 21746068
0
 
LVL 21

Expert Comment

by:oleggold
ID: 21746075
0
 

Author Comment

by:bshort1023
ID: 21771226
Sorry but none of these articles helped.
I think the key to my problem is that this only happens for two users and only when they are logged onto their PC's.  If I log on to their PC I do not get the error.  If they log on to another PC they do not get the error.  For one of the users this code has worked until a few weeks ago.  It is fully repeatable for these two users.

bshort1023
0
 

Author Comment

by:bshort1023
ID: 21793053
Hello.  Anyone?  Bueller?
0
 
LVL 12

Expert Comment

by:nexusnation
ID: 21815331
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 30

Expert Comment

by:hnasr
ID: 21818155
If You run on PC1 AND User runs on PC1 Then
-----Software is fine
-----Privileges are fine for both
If You run on PC2 AND User fails on PC2 Then
-----Software is fine
-----Check privileges for user on this PC
0
 

Author Comment

by:bshort1023
ID: 21846576
nexusnation:  This just looks like a procedure on how to save the workbook.  Was there something more there that I am missing?  I did try doing a SaveAs instead of Save but the only difference is that my error message changes to Method "SaveAS' of object '_Workbook' failed.

hnasr:  Everyone has Full Control on the target directory and I have also tried making the users local admins on their PC's.  Tried changing to a local target directory (noramlly saving to a network location) that the user has full control on and still the same issue.

It seems funny that it lets the user create this spreadsheet but not save it.

I appreciate the responses.
0
 

Author Comment

by:bshort1023
ID: 21847202
I was just able to get on one of the offending PC's and did some more testing.  Hopefully this info will help a little.

When I step through the code I get a different error than when I run the code from a button on a form.  The error is:

Error -2147417851 (same error #)
Automation error
The server threw an exception.

I also noticed that I can save the spreadsheet before I make any changes but as soon as I make the first change to the spreadsheet in the code I will get the error when saving.
0
 
LVL 30

Expert Comment

by:hnasr
ID: 21847499
My previous comment, put differently,
1     You run ok on PC1 & PC2
2     He runs ok on PC1
4     He does not run ok on PC2
----
 x         Total
After you add the numbers of checking actions
Select Case x
-----case 1
----------Software is fine
----------Your privileges are fine
-----Case 3
----------Software is fine
----------Privileges are ok
-----case 5
----------Suspect Privileges
-----case else
----------report
0
 

Accepted Solution

by:
bshort1023 earned 0 total points
ID: 21868690
hnasr:  I understand what your saying about privs but since it would not work on a PC where he is a local admin and everyone has full control to the network location and it does work on a PC where he is not a local admin to the same network location just seems like it is not a privs issue.

Either way the issue is fixed.  I created a new profile for the user on his PC and he can now run the code without any errors.

Thanks for the help anyway.

bshort1023

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now