Microsoft Word - MS Office 2007 issues with Add-In behavior

Asked By Nurali Satani on 22-Jul-10 06:33 AM

Hi,

 

This is Nurali Satani from Cognizant.

 

Currently we are facing some weird issue with Microsoft office 2007.

We support the content management part of the system. This sub-system is a fat client(Desktop Application) & it provides a tree structure view of loan documents stored in our content management to the users. The user can open the document, edit it & check-in the document again.

We've written custom macro/Add-in for Microsoft documents(doc/ppt/xls) such that on click of Save(Cnt + S ) & close, the addIn will invoke application program to checkIn the document into system.

----------------------

Table below describes the recently started unstable behavior scenarios on office 2007.

Also, please have a look at the error messages that we are getting & advise us in case you want us to try anything to resolve this.


# Scenario Status Error if any
1 DOCX: Save 1st Pass  
2 DOCX: Save 2nd & consecutive Fail Run-time error '5487' Says: Word can not complete save ue to file permission error.
3 DOC: Save 1st (On Office 2007) Pass  
4 DOC: Save nth (On Office 2007) Fail Run-time error '5487' Says: Word can not complete save ue to file permission error.
5 XLSX: Save 1st Pass  
6 XLSX: Save 2nd & consecutive Fail On second save, it asks for the SaveAs option & if we click cancel here it gives Run-time error '1004' (Method 'Save' of object '_Workbook'failed). Immediately the dialouge box displaying 'Excel has encountered problem' appears & Excel restarts.
Note: Document gets checked in here for the first save.
7 XLS: Save 1st (On Office 2007) Pass  
8 XLS: Save nth (On Office 2007) Fail On second save, it asks for the SaveAs option & if we click cancel here it gives Run-time error '1004' (Method 'Save' of object '_Workbook'failed). Immediately the dialouge box displaying 'Excel has encountered problem' appears & Excel restarts.
Note: Document gets checked in here for the first save.
9 PPTX: Save 1st Pass  
10 PPTX: Save 2nd & consecutive Fail

On second save, it fails with the error:

'The file can not be saved rightnow because the file is loaded by another user at the moment. You can wait a few moments & try the save again, or you can cancel this save & esave using different file name'

11 PPT: Save 1st (On Office 2007) Pass  
12 PPT: Save nth (On Office 2007) Fail

On second save, it fails with the error:

'The file can not be saved rightnow because the file is loaded by another user at the moment. You can wait a few moments & try the save again, or you can cancel this save & esave using different file name'


Note:


I consulted the MS COE in my company & they told me that it might be because of some patch applied on the system.

We tried uninstalling all the patches that has been applied in last 6 months but the problem still remains.


The application we support has around 4000 users & this happens particularly for Office 2007.


This is very critical issue as we could not find any constructive resolution till now.


Any help in this regard is greatly appriciated.


Thanks a Lot,

~Noor

+91  - 98507 59310

Email: Sattaninurali.n@cognizant.com

Hamit YILDIRIM replied to Nurali Satani on 22-Jul-10 06:43 AM

Hi Nurali,

Solution : You should wait and save with another thread, you can use Timer objects Tick method for saving.
Also I suggest that 
1- You have to control your Save event that maybe calling much than one. 
2- Upgrade your office 2007 with SP1 that is containing much innovation interesting with Save and Close events.


Good Works
Nurali Satani replied to Hamit YILDIRIM on 22-Jul-10 06:51 AM

Thanks Hamit,


Do you mean :

a. On trigger of save event, we should wait for say 2 seconds (Application.onTime)

b. Then call over business logic


I did not get your point 1 here. Would be great if you can elobrate.


Thanks a lot.

~Noor

Hamit YILDIRIM replied to Nurali Satani on 22-Jul-10 07:42 AM

Do not think about first,
Handle your business logic with an event handler just in timer's tick.

Good Works
Nurali Satani replied to Hamit YILDIRIM on 29-Jul-10 05:48 AM
Thanks.

We've tried using the timer but no change in behavior.

If I talk specifically about Word, the problem is programmetically(Throgh Add-On) saving a document.

When we invoke ActivDocument.Save in Work Add-on the problem happens. Also, this does not happen on first save of the opened document but happens while trying to save it 2nd time. It gives that '5487' error as mentioned in the chart while trying to save second time & then on nothing happens on click of Save & when we close the document it again asks if we want to save the changes as different file !

This problem is taking very high visibility in organization due to large user base.

Please provide any more options if you think that can work.

Thanks for your help

~Noor
Hamit YILDIRIM replied to Nurali Satani on 29-Jul-10 10:48 AM

Give me some detail

1- Have you any Antivirus program?
2- Are you using Exchange Server?
3- This module is an AddIn region?
4- Is it a trusted application? (you can try to uncheck any specified security access control)?
5- How are you tried my suggest, (you should use save method in the tick event)?
6- How is range formatting is it unspessified?

maybe you can solve when you preparing my answers :)



Nurali Satani replied to Hamit YILDIRIM on 30-Jul-10 03:33 AM
Thanks Hamit.

Below is answers to the questions you suggested:

1- Have you any Antivirus program?
Yes. Symantec Antivirus & client firewall
2- Are you using Exchange Server?
No. We use LotusNotes email client or MS Outlook. (Not sure what you mean by exchange server) But we don't communicate with any exchange server through Add-Ins
3- This module is an AddIn region?
Yes. The problem that we are facing is with the AddIn code.(If that's what you mean)
4- Is it a trusted application? (you can try to uncheck any specified security access control)?
No security access control is specified in Word.
5- How are you tried my suggest, (you should use save method in the tick event)?
Yes we did & it doesn't work. Somehow, the ActiveDocument.Save() fails in the second consecutive invokation. Then on, it exists silently wothout even saving the document or showing any error. ANd after that when you close the document error 5487 occurs.
6- How is range formatting is it unspessified?
We don't use any range formatting as we understand. So, the answer would be unspecified. But we are not sure.

Hamit, please guide us further with your spontaneous thoughts on the same.

Greatly appriciate your help in this.

Thanks,
~Noor
Hamit YILDIRIM replied to Nurali Satani on 30-Jul-10 08:56 AM

Hi again Nurali,

This is a permission error that you defined before. I have suspected two things in your case.
1- Your file name maybe contains paragraph "\w" or new line "\r" character. It must be ordered string.
2- Your Saving path maybe different than allowed location. That user have to right for writing try to change other exist location.

tyr to find out with this suggestion otherwise send me code snippet

Good works.

Nurali Satani replied to Hamit YILDIRIM on 03-Aug-10 08:44 AM
Thanks Hamit,

I don't think the issue that we're facing has anything to do with the two point that you've suggested.

Below is the code snippet as requested:

--------------
The code snippet that  is used to save the document to the repository on save
Sub CAToolsSave()
System.Cursor = wdCursorWait
    ' PTR 6291 - To Optimize and eliminate small bugs in Add-in files
    On Error GoTo ErrHandher  
      ActiveDocument.Save
    If (IsCAToolsDocument(ActiveDocument.FullName)) Then      ' Function IsCAtoolsDocument checks if it is a system document
        CallFUNBClientEdit "SaveToCat", ActiveDocument.FullName  'Function that saves the document to the repository    
    System.Cursor = wdCursorNormal
ErrHandher:    
    Exit Sub
End Sub

This function is called from the Word Command FileSave()

Sub FileSave()
    If ActiveDocument.ReadOnly _
    Then FileSaveAs _
    Else CAToolsSave
End Sub

When any document is saved the first time, the save is successful and the document gets saved in the repository
But when it saved the second time, Runtime error 5487 occurs.
--------------

Also, today we've found one work around that seems to be working:
1. Save the current document
2. Create a copy of the current document in the same directory with different name
3. Pass on the copied file to the Add In for further processing (Saving into repository)
4. Delete the copied file

Please let us know if it makes any sense to you to understand our problem in a better way.

Thanks a lot,
~Noor