Tag Archives: office

VC + + COM programming error of 0xc0000005: access conflict when reading location 0xfeefef6

Calling COM+ gives you the desired result and returns an error after the last return 0 sentence.

error location in comip.h

void _Release() throw()

{

if (m_pInterface! = NULL) {

m_pInterface – & gt; Release(); // Error reported here

}

}
When I encounter this problem myself, I use m_pInterface->; Release(); Comment out the program no longer reports an error.
Some other ways online:
1.m_pInterface-> Release () into m_pInterface = NULL from http://topic.csdn.net/u/20091120/16/8a9c8d91-9a39-416b-8d8d-8c2cd2a71d3e.html
2. In the program implementation: PTR ->; Release(); To PTR. Release (); From http://topic.csdn.net/u/20091120/16/8a9c8d91-9a39-416b-8d8d-8c2cd2a71d3e.html
3. One statement is that it is a matter of scope. I don’t know much about it. See: http://stackoverflow.com/questions/2653797/why-does-couninitialize-cause-an-error-on-exit
This method has been tried, but it also works. See the following instructions for details.

I’m working on a C++ application to read some data from an Excel file. I’ve got it working, but I’m confused about one part. Here’s the code (simplified to read only the first cell).

//Mostly copied from http://www.codeproject.com/KB/wtl/WTLExcel.aspx 
 
#import "c:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL" 
#import "c:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" 
#import "C:\Program Files\Microsoft Office\Office11\excel.exe" rename ("DialogBox","ExcelDialogBox") rename("RGB","ExcelRGB") rename("CopyFile", "ExcelCopyFile") rename("ReplaceText", "ExcelReplaceText") exclude("IFont", "IPicture") 
 
_variant_t varOption((long) DISP_E_PARAMNOTFOUND, VT_ERROR); 
 
int _tmain(int argc, _TCHAR* argv[]) 
{ 
    DWORD dwCoInit = 0; 
    CoInitializeEx(NULL, dwCoInit); 
    Excel::_ApplicationPtr pExcel;     
    pExcel.CreateInstance(_T("Excel.Application")); 
    Excel::_WorkbookPtr pBook; 
    pBook = pExcel->Workbooks->Open("c:\\test.xls", varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption); 
    Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[1]; 
    Excel::RangePtr pRange = pSheet->GetRange(_bstr_t(_T("A1"))); 
    _variant_t vItem = pRange->Value2; 
    printf(_bstr_t(vItem.bstrVal));     
    pBook->Close(VARIANT_FALSE); 
    pExcel->Quit(); 
    //CoUninitialize(); 
    return 0; 
} 

I had to comment out the call to CoUninitialize for the program to work. When CoUninitialize is uncommented, I get an access violation in the _Release function in comip.h on program exit.
Here’s the code from comip. h, for what it’s worth.

void _Release() throw() 
{ 
    if (m_pInterface != NULL) { 
        m_pInterface->Release(); 
    } 
} 

I’m not very experienced with COM programming, so there’s probably something obvious I’m missing.

    Why does the call to CoUninitialize cause an exception? What are the consequences of not calling CoUninitialize? Am I doing something completely wrong here?

ANSWER!

The problem you are having is one of scope. The short answer is to move the CoInit and CoUninit into an outer scope from the Ptrs. For example:

//Mostly copied from http://www.codeproject.com/KB/wtl/WTLExcel.aspx 
 
#import "c:\Program Files\Common Files\Microsoft Shared\OFFICE11\MSO.DLL" 
#import "c:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\VBE6EXT.OLB" 
#import "C:\Program Files\Microsoft Office\Office11\excel.exe" rename ("DialogBox","ExcelDialogBox") rename("RGB","ExcelRGB") rename("CopyFile", "ExcelCopyFile") rename("ReplaceText", "ExcelReplaceText") exclude("IFont", "IPicture") 
 
_variant_t varOption((long) DISP_E_PARAMNOTFOUND, VT_ERROR); 
 
int _tmain(int argc, _TCHAR* argv[]) 
{ 
    DWORD dwCoInit = 0; 
    CoInitializeEx(NULL, dwCoInit); 
    { 
        Excel::_ApplicationPtr pExcel;     
        pExcel.CreateInstance(_T("Excel.Application")); 
        Excel::_WorkbookPtr pBook; 
        pBook = pExcel->Workbooks->Open("c:\\test.xls", varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption, varOption); 
        Excel::_WorksheetPtr pSheet = pBook->Sheets->Item[1]; 
        Excel::RangePtr pRange = pSheet->GetRange(_bstr_t(_T("A1"))); 
        _variant_t vItem = pRange->Value2; 
        printf(_bstr_t(vItem.bstrVal));     
        pBook->Close(VARIANT_FALSE); 
        pExcel->Quit(); 
    } 
    CoUninitialize(); 
    return 0; 
} 

The longer answer is that the Ptrs destructors (which calls Release) are being called on exit from main. This is after CoUnit which, basically, shuts down the communication channel between your app and the COM object.
What are the consequences of not calling CoUnit?For short lived in-process COM servers, there really isn’t any negative consequence.

IT Skill: How to Recall Email Message in Outlook 2007

In Go Lala Go, a hapless Helen accidentally sends a rather private email to everyone and gets fired, as everyone remembers. In real life, it’s not uncommon to accidentally send an email while it’s still being edited. How to do?Recall it immediately!

For the email Sent just now, find it in the Sent Items Folder. Open it. In the Ribbon screen that opens the email, select the following option:
Actions –> Other Actions –> Recall This Message…


Then, choose from the following dialog:


That will do.

It also is not always going to be successful. If it has already been browsed, it is going to be unsuccessful, so it is going to be fast.

How to Disable Protected View in Microsoft Excel

How to Disable Protected View in Microsoft Excel


You may find that the numbers displayed in your Volatility Backup XLS do not match the numbers in Corporate Focus. This mis-display of numbers is due to the “Protected View” setting within Microsoft Excel. All Microsoft Office files downloaded from the Internet (and Corporate Focus) are “blocked” by default.
There are several ways to get around this issue:
(Recommended)
The simplest and most secure method to get around this issue is to simply click the Enable Editing button, on a per-document basis, when you open an Excel (or other Microsoft office) file that has been downloaded.
(NOT Recommended)
Alternatively, you can choose to disable the Protected View feature within Excel so that you no longer recieve the warning upon opening any Excel file that has been downloaded. In Excel go to File > Options > Trust Center > Trust Center Settings > Protected View, and then uncheck Enabled Protected View for files originating from the Internet.
There is also, in Trust Center Settings, a Macro Setting that you can use to Enable All Macros by default. Be aware that enabling this feature allows potentially dangerous code to run.
If either of these Trust Center settings are changed, you need to be very careful about the Excel files that get opened.
 
 
 
http://www.howtogeek.com/60310/enable-editing-for-all-office-2010-documents-by-disabling-protected-view/
Protected View can stop viruses from installing onto your computer but comes at the price of clicking a button every time you want to edit a document. Here’s how to permanently disable Protected View for all documents in Microsoft Office.
Microsoft added many usability and security features to Office 2010 that help protect end users from embedded plugins and viruses that can crash Office or even install viruses. These features go a long way to keep your computer running smoothly, but there are still options you can tweak to disable Protected View for specific files. To fine tune your Protected View options have a look below.
Disable Protected View for Specific Documents
To get to the protected view options, open Microsoft Word 2010 and then go to file and options.

On the left column click Trust Center and then click Trust Center Settings.

Now on the left column click Protected View and uncheck any documents you would like to open automatically with Protected View disabled. This will allow you to edit the documents without needing to enable editing but may also make your computer an easy target for zero day virus exploits.

Once you check or un-check the settings you want you can close the windows. Repeat these steps for Microsoft Excel and Powerpoint if you want to disable Protected View there too.
Modify Safe Locations
To add more locations that are marked as safe for Protected View go back to the Trust Center Settings and click Trusted locations on the left.

Click add new locations at the bottom and browse to the location you would like to add to the trusted locations list.

Any documents in the new location will now be marked as safe.
Disable Protected View from Registry
Like most options in Windows there is a way to disable these settings via the registry too. If for some reason the options in Office do not work or you want to be able to automate this setting for multiple computers you can try setting one or more of these registry values below.

HKCU\Software\Microsoft\Office\14.0\Word\Security\ProtectedView

HKCU\Software\Microsoft\Office\14.0\Excel\Security\ProtectedView

HKCU\Software\Microsoft\Office\14.0\PowerPoint\Security\ProtectedView

The three values you would want to set are:
DisableAttachementsInPV
DisableInternetFilesInPV
DisableUnsafeLocationsInPV
By setting each value to 1 you will disable Protected View for that file location.
 

How to solve the Mapi error of outbook that can’t send mail directly

Recently, when I upgraded from office2010 to 2013, I found that the right file could not be sent to the email. Meanwhile, in word document, it could not be sent to the email as an attachment.
Error:
Mapi Failure – “Unspecified Error”, meaning Mapi Error: The cause is Unspecified.

Through research, find an article: http://answers.microsoft.com/en-us/office/forum/officeversion_other-word/word-could-not-send-mail-because-of-mapi-failure/f62678fe-ef1d-42b5-8cfe-1e43d6a1d609?auth=1

The solution:
HKEY_Current_User> Software> Microsoft> Office> 15.0 & gt; Outlook> Preferences> MaximumAttachmentSize
Change the value 0 to another value, such as 5000, to indicate that an attachment of 5M size can be sent. Of course, you can also make it bigger, like 50000m, 50m!

All right, problem solved!