Save-problems in Powerpoint and Excel

P

Peter Karlström

Hi

In a VB6-developed COM-Addin for Office 2007, we have experience problems
working with files from a web-interface.
We have solved the issue in Word 2007, but we have difficulties to implement
the same strategi for Powerpoint presentations and Excel Spreadsheets.
The error we handle in Word is 5487 (Permission denied).

When we issue the appObj.Activepresentation.Save command, and the file is
locked, we get a message telling us to Abort or Retry.
We don't want that message to show, and appObj.DisplayAlerts = ppAlertsNone
doen't work.
The error returned if we choose Abort is -2147467259, but the message we
presents with that error should be the only one.

Is there another way to supress this message?

Whe we try the same in Excel, a Save As dialogue is displayed.
We don't want that dialogue either.


Thanks in advance for any help
 
C

Colbert Zhou [MSFT]

Hello Peter,

I write codes to test in my side but cannot reproduce the issue. My codes
create a button on the PowerPoint 2007 ribbon and when the button is
clicked, my codes call the app.ActivePresentation.Save() method. I compile
the project and make sure the AddIn loads correctly. I use PowerPoint 2007
open a network .ppt file from our SharePoint web interface. After it is
opened, I make some changes and click my addin button. It works correctly
and does not pop up any message.

I am not sure if this is the exactly same scenario as in your side. But I
think,

1.Make sure the Office product has the latest SP installed. As for Office
2007, it is SP2.

2.Then, coiuld you please give some more detailed information about your
scenario, like what kind of file you open in the PowerPoint. And what do
you mean the file is locked. Is there any status message we can observer
for this lock status.


Best regards,
Colbert Zhou
Microsoft Newsgroup Support Team
 
P

Peter Karlström

Hi Colbert

Thank you for your reply.

The problem regarding the Word part is previously posted here on this link:
http://www.microsoft.com/communitie..._ins&mid=ded9b179-5a3f-4cad-b481-35debbe2d5b2
Topic is Word document opened from browser., Jie Wang has supported us in
this.

It seems Internet Explorer doesn't close the file directly when the document
is opened from my customers web-system. There is an approx. 60 seconds delay
in this, causing this error if you try to save the document immediately.

In Word we trap this error (5487) and displays a message about this to the
user.

Now, this procedure doesn't work for Powerpoint and Excel, since these
programs have another strategy for handling locked files.

Jie Wang has Process Monitor dumps of this scenario, and I can send these to
you if you think they are useful.
I also think Jie created a web environment in where he could reproduce our
error.

SP2 is installed after first encounter of the problem, but with the same
results.
Both IE7 and IE8 is tested. Same result.


Best Regards
 
P

Peter Karlström

Problem solved!

Since I didn't have any control over the behaviour in Powerpoint and Excel,
I desided to create a process-check which could be executed before the actual
save-method is invoked. It didn't work using Shell-function, so I creates a
little cmd-file holding the command.

I used Sysinternals handle.exe, started it with the file-name of the
IE-locked file and piped it to e textfile. The I scanned the textfile for the
processname iexplore.
If I get a hit, I return True, otherwise I return False.

This actually works perfectly for all three Office-parts for which the
COM-Addin is developed. There is also no dip in performance. The check runs
fast.

Here is the function if anybody is interested:

Public Function isFileLocked(ByVal iFilename As String, ByVal iProcess As
String) As Boolean

Const MethodName As String = "isFileLocked"

Dim sErr As String
Dim resp As Long
Dim cmdString As String
Dim tString As String
Dim tmpPath As String
Dim resFile As String
Dim tmpCmdFile As String
Dim fs As FileSystemObject
Dim f As File
Dim ts As TextStream

On Error GoTo ErrHandler

tmpPath = Environ("TEMP")
If tmpPath = "" Then tmpPath = "C:\"
If Right(tmpPath, 1) = "\" Then
resFile = tmpPath & "filecheck.lex"
tmpCmdFile = tmpPath & "filecheck.cmd"
Else
resFile = tmpPath & "\filecheck.lex"
tmpCmdFile = tmpPath & "\filecheck.cmd"
End If
On Error Resume Next
Kill resFile
On Error GoTo ErrHandler
If Len(iFilename) > 35 Then
iFilename = Right(iFilename, 35)
End If
cmdString = "handle " & iFilename & " > " & resFile

Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.CreateTextFile(tmpCmdFile, True, False)
ts.WriteLine cmdString
ts.Close

Set ts = Nothing

resp = Shell(tmpCmdFile, vbHide)

Err.Clear
Set f = fs.GetFile(resFile)
If Err.Number = 0 Then
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
Do While Not ts.AtEndOfStream
tString = ts.ReadLine
If InStr(UCase(tString), UCase(iProcess)) > 0 Then
isFileLocked = True
Exit Do
End If
Loop
ts.Close
Else
sErr = Now & " ERROR " & CStr(Err.Number) & " at line " & Erl & " in " &
MethodName & " (" & Err.Description & ")."
logTrace.WriteEntry sErr
End If

Set ts = Nothing
Set f = Nothing
Set fs = Nothing

Exit Function

ErrHandler:
sErr = Now & " ERROR " & CStr(Err.Number) & " at line " & Erl & " in " &
MethodName & " (" & Err.Description & ")."
#If MSG_MODE Then
MsgBox sErr, vbCritical, App.EXEName
#End If
#If LOG_MODE Then
logTrace.WriteEntry sErr
#End If
isFileLocked = False

End Function


Best Regards
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top