IPersistFile::Save not working with Word 2007

M

Maksim Zanko

Hi All,

We are developing a custom solution, based on the DSOFramer component from
Microsoft. Recently we began testing our solution with Office 2007.

The following problem was encountered during testing:
When we are trying to save a Word 2007 document using IPersistFile::Save
API, it does not work.
The function returns S_OK, however the document file is not created on disk.
NTFS persmissions on target drive allow write access.
It all works fine for Office 2000, XP and 2003, as well as for Excel and
PowerPoint applications from Office 2007 suite. It fails only for Word 2007.

Please advise if we can expect a fix in the nearest future. Fixing the issue
is very important for us, because it affects our shipping schedule.

Regards,
Maksim Zanko
 
M

Michael Cessna

Maksim,

This is a definite bug in Microsoft Word 2007.

I posted a quick solution a while back:

http://groups.google.com/group/micr...essna+dsoframer&rnum=2&hl=en#b39c9ac75f4fb42a

Also, here is another workaround:

<Quote>

As the IPersistFile::Save does get through successfully, I think another solution would be to:

1) Check if IPersistFile::Save succeeded.

2) If yes, check if the resultant file exists.

3) If the file does not exist then rename IPersistFile::GetCurFile to be the file that we want.



Here is the code that I used for this:

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

if (SUCCEEDED(hr = m_pole->QueryInterface(IID_IPersistFile, (void**)&pipfile)))

{

//Get the current open file

LPWSTR pwszCurPath = new WCHAR(MAX_PATH+1);

pipfile->GetCurFile(&pwszCurPath);



//Perform save.

hr = pipfile->Save(pwszFile, FALSE);

pipfile->Release();



//Save results S_OK, but the document is saved to the original location (IPersistFile->GetCurFile) in Word 2007.

//We will just check if that's the case and move the file.

if (SUCCEEDED(hr) && !FFileExists(pwszFile))

{

//We should come here only in case of Word 2007.

CopyFileW(pwszCurPath, pwszFile, TRUE);

}

}

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



This did work for the tests that I carried out. However, I have not tested this exhaustively.


</Quote>

Of course, both of these solutions are "use at your own risk"...still waiting for a fix from Microsoft to Microsoft Word 2007.

Thanks.

Mike
 

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