Hello Ole programmers,
I am debugging an application that has a strange problem. It is an MFC
application that is implementing VBA (Using VBA SDK 6.0 V6.3).
There is an file autobackup feature that sometimes fail and a MessageBox
with "Path/File access error" message is displayed. After that error is
displayed it seems that the ApcProject is corrupted.
Here is the code that causes the problem
// Save the contents
BOOL fSaveProject = !!ApcProject;
if (fSaveProject)
{
HRESULT hr = ApcProject.Save(pStorage, FALSE);
fNeedSaveCompleted = !ApcGetEmbedded(this);
if (FAILED(hr))
{
g_pDebugLog->Write("===> SaveToStorageAuto...
ApcProject.Save Failed! hr: %d", hr);
AfxThrowOleException(hr);
}
}
// Serialize uses the m_lpRootStorage
m_lpRootStg = pStorage;
Serialize(saveArchive);
m_lpRootStg = pOrigStg;
if (fSaveProject)
{
fNeedSaveCompleted = FALSE;
// resets the ApcProject to the Original Storage
HRESULT hr = ApcProject.SaveCompleted(NULL);
g_pDebugLog->Write("SaveToStorageAuto save completed hr:
%d", hr);
ASSERT(SUCCEEDED(hr));
}
Additionnal informations :
- The problem is on the SaveCompleted line. Even if the problem occurs the
hr is S_OK.
- It only happens when the autobackup is running and the user is typing code
in VBA IDE.
- The pStorage pointer points to the backup storage (not the original
storage). This Storage is created earlier with a call to
::StgCreateDocfile(T2COLE(strAutoBackup),
STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE|STGM_CREATE,
0,
&lpStorage);
- I have tried to use the IApcProject::SaveCopyAs method to make a backup
copy but it always returns APC_E_NOPERMISSION and i don't know why.
There is not much help about these topic.
PLEASE HELP!!
Regards
Oli
Archived from group: microsoft>public>vb>ole