This is probably due to version compatibility. The file is in doc format, while your word version is 07 or higher.
Formulas cannot be inserted when modeling mode is on.
Save as a new docx format.
This is probably due to version compatibility. The file is in doc format, while your word version is 07 or higher.
Formulas cannot be inserted when modeling mode is on.
Save as a new docx format.
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.
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.
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.
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.
All right, problem solved!