VS MFC下操作excel时 Open出错(debug模式正确release报错),求助

hdzhangnudt 2017-06-06 12:36:09
以下代码在debug模式下正常,一旦到release或release static下,则执行到Open就报错,
(VS2010,MFC,win7,32bit)

CApplication oApp;
CWorkbooks books;
CWorkbook book;
CWorksheets sheets;
CWorksheet sheet;
CRange range;
CRange rangV;
CString sTotalDangAn,strTotalUser,strTotalXingHao;
oApp.CreateDispatch(_T("Excel.Application"));
books = oApp.get_Workbooks();
book = books.Open(sPath, _variant_t(vtMissing),_variant_t(vtMissing), _variant_t(vtMissing), _variant_t(vtMissing),
_variant_t(vtMissing), _variant_t(vtMissing),_variant_t(vtMissing), _variant_t(vtMissing),_variant_t(vtMissing),
_variant_t(vtMissing),_variant_t(vtMissing),_variant_t(vtMissing),_variant_t(vtMissing),_variant_t(vtMissing) );

执行到此处后,转到:AfxCallWndProc的
CATCH_ALL(e)
{
lResult = AfxProcessWndProcException(e, &pThreadState->m_lastSentMsg);
TRACE(traceAppMsg, 0, "Warning: Uncaught exception in WindowProc (returning %ld).\n",
lResult);
DELETE_EXCEPTION(e);
}
...全文
1313 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhujinqiang 2017-07-21
  • 打赏
  • 举报
回复
设置断点调试一下
zgl7903 2017-07-20
  • 打赏
  • 举报
回复
Release 版本也可以设置断点调试运行
liuyuzhen_smile 2017-07-20
  • 打赏
  • 举报
回复
是不是变量赋值不对或者有的变量没有赋值导致的,自己调试看看
oyljerry 2017-06-06
  • 打赏
  • 举报
回复
先看看错误的信息是什么,是不是有配置跟debug不一致
huangzongw 2017-06-06
  • 打赏
  • 举报
回复
检查一下debug下传人的调试路径与releas下的是否不同,如果sPath是相对路径,调试目录不同的话会有影响
调试程序可以帮助了解程序是怎样运行的。 1、如何快速地规范代码缩进格式 选中所需要规范的代码,按shift+F8 2、如何在Release状态下进行调试 Project->Setting…->Project Settings对话框,选择Release状态。“C/C++”标签页中的Category选General,Optimizations选Disable(Debug),Debug info选Program Database。在“Link”标签页中选中Generate debug info复选框。 注:只是一个介乎DebugRelease的中间状态,所有的ASSERT、VERIFY都不起作用,函数调用方式已经是真正的调用,而不查表,但是这种状态下QuickWatch、调用队列跟踪功能仍然有效,和Debug版一样。 3、ReleaseDebug有什么不同。 Release版称为发行版,Debug版称为调试版。 Debug中可以单步执行、跟踪等功能,但生成的可执行文件比较大,代码运行速度较慢。Release版运行速度较快,可执行文件较小,但在其编译条件下无法执行调试功能。 Release的exe文件链接的是标准的MFC DLL(Use MFC in a shared or static dll),比如MFC42.DLL。这些DLL在安装Windows的候,已经配置,所以这些程序能够在没有安装Visual C++ 6.0的机器上运行。而Debug版本的exe链接了调试版本的MFC DLL文件,如MFC42D.DLL。在没有安装Visual C++6.0的机器上不能运行,因为缺MFC42D.DLL等,除非选择use static dll when link。 4、ASSERT和VERIFY有什么区别 ASSERT里面的内容在Release版本中不编译,VERIFY里面的内容仍然编译,但不再判断真假。所以后者更安全一点。 例如ASSERT(file.Open(strFileName)),一旦到了Release版本中,这一行就忽略了,file根本就不Open()了,而且没有任何出错的信息。如果用VERIFY()就不会有这个问题。 5、Workspace和Project之间是什么样的关系 每个Workspace可以包括几个project,但只有一个处于Active状态,各个project之间可以有依赖关系,在project的Setting…中可以设定,比如那个Active状态的project可以依赖于其他的提供其函数调用的静态库。 6、如何在非MFC程序中使用ClassWizard 在工程目录下新建一个空的.RC文件,然后加入到工程中就可以了。 7、如何设置断点 按F9在当前光标处增加一个断点和取消一个断点。 另外,在编辑状态下,按Ctrl+B组合键,弹出断点设置对话框。然后单击【Condition…】按钮弹出设置断点条件的对话框进行设置。 8、在编辑状态下发现成员变量或函数不能显示提示,如何打开显示功能 这似乎是目前这个Visual C++ 6.0版本的一个bug,可按如下步骤使其正常,如再出现,可如法炮制: (1)关闭Project,(2)删除“工程名.ncb”文件,(3)重新打开工程
可再发行编码 - 有限使用: msjet35.dll msjint35.dll msjter35.dll msrd2x35.dll msrepl35.dll expsrv.dll vbajet32.dll msexch35.dll msexcl35.dll mspdox35.dll msltus35.dll mstext35.dll msxbse35.dll MSJTOR35.DLL MSJT4JLT.DLL mdac_typ.exe msorcl32.dll msdaora.dll 可再发行代码 - 扩展的使用: comct232.ocx comct332.ocx comctl32.ocx comdlg32.ocx dblist32.ocx hhctrl.ocx mci32.ocx msadodc.ocx mschrt20.ocx mscomct2.ocx mscomctl.ocx mscomm32.ocx MSDatGrd.ocx msdatlst.ocx MSDatRep.ocx msflxgrd.ocx mshflxgd.ocx msinet.ocx msmapi32.ocx msmask32.ocx msrdc20.ocx mswinsck.ocx picclp32.ocx richtx32.ocx sysinfo.ocx tabctl32.ocx wbclsdsr.ocx anibtn32.ocx dbgrid32.ocx gauge32.ocx graph32.ocx grid32.ocx gswdll32.dll keysta32.ocx mschart.ocx msoutl32.ocx spin32.ocx threed32.ocx adodcchs.dll cmct2chs.dll cmct3chs.dll cmctlchs.dll cmdlgchs.dll datgdchs.dll datlschs.dll DatRpchs.DLL DBGRDCHS.DLL dblstchs.dll flxgdchs.dll mcichs.dll MsCc2chs.dll msch2chs.dll MSCMCCHS.DLL MSCOMCHS.DLL MSHFGCHS.DLL inetchs.dll MSMPICHS.DLL MSMSKCHS.DLL rdc20chs.dll WINSKCHS.DLL pcclpchs.dll rchtxchs.dll SYSINCHS.DLL TABCTCHS.DLL mswcrchs.dll MSCHTCHS.DLL 可再发行代码 - 标准: oleaut32.dll secur32.dll compobj.dll ole2.dll ole32.dll olecnv32.dll olethk32.dll rpcltc1.dll rpcltc5.dll rpcltccm.dll rpclts5.dll rpcltscm.dll rpcns4.dll rpcrt4.dll rpcss.exe storage.dll stdole2.tlb stdole32.tlb imagehlp.dll dllhost.exe comcat.dll iprop.dll rpcmqcl.dll rpcmqsvr.dll olepro32.dll asycfilt.dll mfc40.dll msvcrt40.dll dcomcnfg.exe oledlg.dll ciscnfg.exe dcomcnfg.hlp IE4\MSJavx86.exe os\system\atl.dll os\system\ansi\atl.dll VB98\template\code\loadres.bas VB98\template\code\RegKeys.BAS VB98\template\controls\ListBtns.frm VB98\template\controls\ListBtns.frx VB98\template\controls\listpick.frm VB98\template\controls\listpick.frx VB98\template\controls\tvlv.frm
使用方法: 1、解压至C:\Program Files目录下(密码:xiaoqing); 2、双击导入注册表C:\Program Files\BCGSoft\BCGControlBarPro\bcgcontrolbarpro.12.00.reg; 3、运行向导C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBProIntegrationWizard.exe。 与其它不同之处: 1、包含完整的源代码、帮助文件; 2、已经对 BCGPAppWizard2005 中的向导进行汉化,在 Visual Studio 2008(2010) 中可使用中文向导 BCGPAppWizard (参考 Visual Studio 2008 原有的中文向导,如果您想学习汉化向导,参考目录是:C:\Program Files\Microsoft Visual Studio 9.0\VC\VCWizards\AppWiz\MFC\Application\templates\2052) 关于静态链接: 1、首先必须在运行向导BCGCBProIntegrationWizard.exe已经编译静态库; 2、在 Visual Studio 建立项目向导,选择静态链接即可。 关于使用 Office2007、2010 风格: 如果您使用了这些新风格,必须在项目中包括这些资源,否则 debug 版本启动报错(缺少资源,release版本不会提示,但显示不正常),具体有二种方法: 1、直接在“解决方案资源管理器”-“资源文件”中点右键,“添加”-“现有项”,把C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles中所有扩展名为 .rc 的资源包括进来即可。 2、直接在“资源视图”-“您的项目”上点右键,选择“资源包括”,在“资源包括”中的“编译指令”中的#include "BCGCBPro.rc"后面添加以下代码: #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Aqua.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Luna.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Obsidian.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2007Silver.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyle2010White.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyleCarbon.rc" #include "C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\BCGPStyleScenic.rc" 3、如果使用动态库链接,请手工编译C:\Program Files\BCGSoft\BCGControlBarPro\BCGCBPro\Styles\Office2007_styles.sln或者build_all.dsp 仅为学习使用,下载后24小内删除,请支持 BCGSoft 购买正版,本人不提供技术支持,不对任何负责。 尊重他人劳动成果,欢迎与大家分享成果。 官方更新说明: http://www.bcgsoft.com/bcgcontrolbarpro-versions.htm Version 12.0. Released 01/20/2010 New features CBCGPVisualManager2010 implements Microsoft Office 2010 Beta 1 color themes: Blue theme (see screenshot) Black theme (see screenshot) Silver theme (see screenshot) Just activate CBCGPVisualManager2010 to use these new themes in your application: CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CBCGPVisualManager2010)); Please run BCGPMSOffice2007Demo, DrawCli or BCGPOrganizer to see this feature in action. Added Microsoft Office 2010-style Ribbon Backstage View (see screenshot). The following new methods were added to CBCGPRibbonBar class: SetBackstageMode: enables/disables Backstage View mode. IsBackstageMode: returns TRUE if Backstage View mode is enabled. AddBackstageCategory: creates Backstage View category. GetBackstageCategory: returns Backstage View category. IsBackstageViewActive: returns TRUE if Backstage View is currently active. By default, the Ribbon Application button will be displayed with the default (blue) color, but developers can customize its appearance by calling visual manager's new method 'SetMainButtonColor' (see screenshot). CBCGPRibbonBar::AddBackstageCategory returns a pointer to the new class object - CBCGPRibbonBackstageViewPanel. Usually, you'll need to call the following class methods to create your backstage view: AddCommand: add a single command button such as "Save", "Save As" or "Exit". AddView: add a button with attached right-side form ("Print", "Recent Files" and so on). There are 2 new classes that should be used for implementing right-side views: CBCGPRibbonBackstageViewItemForm: a single page dialog CBCGPRibbonBackstageViewItemPropertySheet: multi-page Please note that our Application Wizards were updated and now, when you're creating a new, Ribbon-based application, you can choose "Backstage view" option (see screenshot) and initial backstage view code will be automatically generated for your pleasure!. The Ribbon bar Application ("main") Button can display a text label instead of icon in the "scenic" mode (usually "File" in English language UI). The following new methods were added to the CBCGPRibbonMainButton class: SetScenicText GetScenicText Implemented ability to add Ribbon Galleries to the dialogs (see screenshot). The new class CBCGPRibbonGalleryCtrl may be used for this purpose. Please take a look at BCGPMSOffice2007Demo example (Backstage view pages) to see this new control in action. Implemented Resizable Dialogs support (see screenshot1 and screenshot2): Added 2 new classes: CBCGPControlsLayout: implements the base class for all layout managers. CBCGPStaticLayout: implements "static" layout management based on anchors. To enable layout support, you've to call EnableLayout/GetLayout methods in the following classes: CBCGPDialog CBCGPDialogBar CBCGPropertyPage CBCGPFormView Please run ResizableForm new sample to see this feature in action. In addition, you can see this feature in the following examples and samples: BCGPMSOffice2007Demo: "Clipboard" Pane and Backstage view. BCGPOrganizer: resizable dialog bar. RibbonGadgets: backstage view. ToolBoxDemo: resizable form Significantly improved CBCGPVisualManagerVS2010 (see screenshot): The color scheme is identical to Visual Studio 2010 Beta 2. Added a new Smart Docking style (BCGP_SDT_VS2010). You can run BCGPVisualStudioGUIDemo example to examine this look. Added content scrolling support to CBCGPDockingControlBar-derived classes (see screenshot). By default, the scrolling is implemented in CBCGPDialogBar class only, but you can easily add this support to any CBCGPDockingControlBar-derived class (please take a look at BCGPGridExample example, COutputBar class). CBCGPDockingBarScrollButton class implements docking pane scroll button (vertical and horizontal) and its look depends on the currently activated visual manager. Calculator control has been significantly improved: All calculator buttons are drawn using built-in bitmaps and use visual manager appearance (see screenshot). Implemented extended commands. Using a new method CBCGPCalculator::SetExtendedCommands developers can add a lot of build-in calculator commands such as idCommandAdvSin, idCommandAdvCos, idCommandAdvTan and others. CBCGPRibbonComboBox allows to display a popup calculator window. Just call CBCGPRibbonComboBox::EnableCalculator method to assign a calculator to the ribbon combobox. Override a new 'OnCalculatorUserCommand' method to implement your calculator commands. Please take a look at BCGPControls example and RibbonGadgets/SkinnedDialog samples to see these new features in action. The following new methods were added to CBCGPVisualManager class: OnDrawDockingBarScrollButton OnDrawCaptionBarCloseButton GetHeaderCtrlTextColor OnFillPropSheetHeaderArea OnDrawDateTimeDropButton GetCalculatorButtonTextColor GetEditCtrlSelectionBkColor GetEditCtrlSelectionTextColor OnDrawDlgSizeBox OnFillRibbonBackstageForm OnDrawRibbonMinimizeButtonImage GetRibbonMinimizeButtonImageSize GetRibbonButtonsGroupHorzMargin IsDrawRibbonGroupSeparator OnDrawRibbonGroupSeparator GetRibbonBackstageTopLineHeight OnDrawRibbonBackstageTopLine SetMainButtonColor GetMainButtonColor IsOwnerDrawDlgSeparator OnDrawDlgSeparator CBCGPPropertySheet has a new mode: PropSheetLook_AeroWizard (see screenshot). In general, this mode has been designed and implemented for Vista/Windows 7 Aero, but you can use it in any OSs/modes (see screenshot). The glass (aero) area can be combined with a page header - we've added a new optional parameter 'bDrawHeaderOnAeroCaption' to EnablePageHeader method. Please take a look at PropSheetDemo sample to see this mode. Added support for the Internet Explorer-like new tab in CBCGPTabWnd class (see screenshot). Call EnableNewTab method to enable this feature. Please take a look BCGPIE7Demo example to see this feature in action. Grid and Report controls changes: Added option to select items by clicks on grid header: New header flag BCGP_GRID_HEADER_SELECT. Implemented color themes for the new visual managers such as CBCGPVisualManager2010 (Office 2010-like) and CBCGPVisualManagerVS2010 (Visual Studio 2010-like) (see screenshot). Improved grid printing support. The following new classes were added: CBCGPGridPage class: this class is used by the grid control to store print pages. A print page specifies which area of the grid is printed at the specified page. The grid counts in items in vertical direction. The grid counts in pixels in horizontal direction. CBCGPGridPageInfo class: This class is used by the grid control to store information about the printing range and the currently printing page. It is stored in CBCGPGridCtrl::m_PrintParams::m_pageInfo member and in CPrintInfo::m_lpUserData member of the CPrintInfo object used while printing at the current print session. Added an option to deselect items. To deselect an item please use SetCurSel with SM_INVERT_SEL flag. New functions were added: CBCGPGridCtrl::EnableInvertSelOnCtrl CBCGPGridCtrl::IsInvertSelOnCtrlEnabled Changes in header click events: New BCGM_GRID_COLUMN_CLICK message. Added CBCGPGridCtrl::OnHeaderColumnRClick. Modified CBCGPGridCtrl::OnHeaderColumnClick. Items align support: New CBCGPGridItem::GetAlign function. Item's alignment is specified by CBCGPGridCtrl::SetColumnAlign. Grid horizontal pagination support. Added CBCGPGridPage::m_nWidth - page width, CBCGPGridPageInfo::m_nPageWidth - width of currently printed page. See CBCGPGridPage class, CBCGPGridPageInfo class. Drag-and-Drop support (see new "Drag and Drop" tab in BCGPGridExample sample): New message BCGM_GRID_BEGINDRAG. Added methods EnableDragSelection, IsDragSelectionEnabled, EnableDragSelectionBorder, IsDragSelectionBorderEnabled, StartDragItems and HitTestSelectionBorder. Extended in-place edit customization support (see new "Easy Input" tab in BCGPGridExample sample): New messages BCGM_GRID_ITEM_BEGININPLACEEDIT, BCGM_GRID_ITEM_ENDINPLACEEDIT. New functions OnBeginInplaceEdit, OnEndInplaceEdit, CanBeginInplaceEditOnChar, CanEndInplaceEditOnChar, OnInplaceEditKeyDown, OnInplaceEditSetSel. New BCGPGRID_ITEM_INFO::dwResultCode member. See BCGPGRID_ITEM_INFO struct. New method SetClearInplaceEditOnEnter. Call SetClearInplaceEditOnEnter (FALSE) to disable grid from clearing content of the item on Enter. Added CBCGPGridCtrl::GoToNextItem method. CBCGPGridCtrl::EnsureVisible is now virtual. Added navigation by TAB (Shift+TAB) key. Added "Ctrl+Z" (Undo) handler for in-place edit of the grid item. Changes in CBCGPGridCtrl::SetCurSel for SM_SET_ACTIVE_ITEM style. Grid item with combo-box now supports F4 to open drop-down list. Added a new parameter CBCGPMDITabParams::m_bReuseRemovedTabGroups. If this flag is TRUE MDI tab groups which were marked as removed will be used for new groups. This reduces memory consumption for applications that frequently create and remove groups. Added OpenType font support for font combo boxes. Added keyboard and MS Active Accessibility support to CBCGPTasksPane class. CBCGPEditCtrl::ExportBuffer has a new optional parameter 'BOOL bForceAnsi'. Setting it to TRUE forces exporting editor's text in ANSI format. CBCGPRibbonStatusBarPane constructor and SetAnimationList method have a new optional parameter 'BOOL bDontScaleInHighDPIMode'. Set it to TRUE if you don't need to scale pane image in the High DPI mode. When user clicks on the glass area of CBCGPExplorerToolBar window, the application window is moved now. Added CBCGPCalendarBar::GetState method - returns the calendar style flags specified in SetState method. CBCGPRibbonEdit displays a drop-down window upon pressing F4 key. Added CBCGPShellManager::IsControlPanel method. Added new font 'fontCaption' to BCGPGLOBAL_DATA. This font will be useful for displaying caption texts. CBCGPStatic has a new member: m_clrText. You can set this member to colorize text labels (see SkinnedDialog sample). New method CBCGPDockManager::ShowFloatingBars shows/hides floating panes. CBCGPListBox control can work with left-side icons and item group headers now. The following new methods were added: SetImageList: set items image list SetItemImage: associate item with a specific icon AddCaption: add a group caption Changes in examples and samples: BCGPControls: "Calculator" page demonstrates new calculator features BCGPGridExample: added new visual managers and new 2 tabs: "Drag and Drop" and "Easy Input" BCGPIE7Demo: the tab control was fully redesigned and derived from the library MDI Tab control. BCGPMSOffice2007Demo: added MS Office 2010 Backstage view. "Clipboard" pane demonstrates a new layout manager. BCGPVisualStudioGUIDemo: Start Page view can be converted to docking control bar. DrawCli: added MS Office 2010 Backstage view and new visual managers. PropSheetDemo: added Aero Wizard demonstration. ResizableForm: new sample, demonstrates how to use a new layout manager along with dialogs, dialog bars, property sheets and form views. RibbonGadgets: added MS Office 2010 Backstage view and edit boxes with calculator. SkinnedDialog: added edit box with calculator and text labels with a custom colors. Changes in the Ribbon Designer: Added "Calculator" element. Support for three new styles introduced in Microsoft Office 2010 (blue, silver, black) Ribbon elements can be edited by double click. Image lists can be loaded from files. Implemented icon editing for Palette (Gallery) Buttons. Fixes: FireChangingActiveTab is called from CBCGPOutlookWnd::SetActiveTab now. Fixed resource leak in CBCGPUserTool::DrawToolIcon Fixed problem with a slider's thumb location in CBCGPRibbonSlider::SetThumbRect in the High DPI mode. Improved appearance of the calendar drop-down button in CBCGPDateTimeCtrl. Fixed problem with setting editbox auto-complete mode in Windows 9x/NT4 CBCGP***FrameWnd::WinHelp dwData parameter has DWORD_PTR type now. This fixes 64-bit compatibility issue with this virtual method. Fixed memory leak in CBCGPPngImage::LoadFromBuffer (VS.NET 2003 or higher, BCGP_EXCLUDE_GDI_PLUS is defined). CBCGPGroup is properly handles WM_SETTEXT message now. CBCGPCalendar always closes dropped-down month picker when the calendar is being destroyed. CBCGPRibbonEdit::OnDraw correctly draws edit box label in case of center/right-side control alignment. Fixed appearance of CBCGPExCheckList items in the high DPI mode (under VC++ 6.0). Fixed problem with displaying disabled check boxes (CBCGPButton class) when some visual managers are activated. Fixed problem with CBCGPHeaderCtrl items text color when some visual managers are activated. Fixed problem with vertical scrolling of elements in CBCGPRibbonPanel::OnKey. CBCGPEdit correctly draws a browse button image and text when control is located on the glass (aero) area. CBCGPEdit uses visual manager color them when control has ES_READONLY style. CBCGPStatic doesn't perform the custom drawing if it has a style like icon, rectangle or frame. CBCGPPropertySheet: fixed some problems with repositioning and redrawing navigation buttons. Fixed some visual problems in owner-draw frame/dialog captions. Ribbon Main Button scenic icon is correctly painted in high DPI mode now. Fixed problem with text alignment in grid columns. CBCGPGridCtrl::SetColumnAlign is working properly now. Fixed bug with using different horizontal color and vertical color for the grid lines. The m_clrVertLine setting did not work when m_bGridItemBorders flag was switched on. Fixed problem with clicking on CBCGPGridURLItem in read-write mode. Fixed a bug with automatic sizing of grid columns. The bug appeared when auto-sizing was enabled with EnableColumnAutoSize(TRUE). Fixed bug with "Ctrl+A" for in-place editing of grid items. "Ctrl+A" selects all text inside in-place editor during in-place editing, instead of the entire grid as before. Fixed memory leak in CBCGPGridCtrl::CopyHtmlToClipboardInternal. Ribbon Designer supports Visual Studio 2008 and Visual Studio 2010 Beta 2 projects.

3,245

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧