当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: 比如有一个类,用以数据访问: using system; using system.data; using system.data.sqlclient; using system.configuration; namespace dbbase public class base { protected static string strconn = configurationsetting......
    摘要: 谁有这方面的经验或资料请赐教!!! ......


VB高手进

我写了一个用来调整文档大小的程序,而且已经定义了:On   Error   GoTo   OBJERROR      
        OBJERROR:  
   
          If   Err   <>   429   And   Err   <>   4605   Then  
                  objWord.Quit  
                  Set   objWord   =   Nothing  
                  Exit   Sub  
          Else  
                  Resume   Next  
          End   If  
   
  为什么,当找不到文件时,扑捉不到他的出错信息,他先弹出一个对话框,“文件未找到”,然后才进OBJERROR:里面?怎么样才能扑捉到着个错误呢??以下是原程序。希望懂的高手解答~~谢谢。  
   
  Option   Explicit  
   
  Sub   Main()  
   
          MsgBox   CStr(Command)  
           
          Dim   objWord   As   Word.Application  
          Dim   objWordDoc   As   Word.Document  
          Const   CLASSOBJECT   =   "Word.Application"  
           
          On   Error   GoTo   OBJERROR  
           
          Set   objWord   =   CreateObject("Word.Application")  
          objWord.Visible   =   False  
           
          Set   objWordDoc   =   objWord.Documents.Open(CStr(Command),   ,   1,   ,   "11",   "11")  
           
          With   objWordDoc.PageSetup  
                          If   .Margin   <   40   Then  
                                  .Margin   =   CentimetersToPoints(1.1)  
                          End   If  
                          If   .BottomMargin   <   40   Then  
                                  .BottomMargin   =   CentimetersToPoints(1.37)  
                          End   If  
                          If   .LeftMargin   <   40   Then  
                                  .LeftMargin   =   CentimetersToPoints(1.27)  
                          End   If  
                           
                          If   .RightMargin   <   40   Then  
                                  .RightMargin   =   CentimetersToPoints(1.32)  
                          End   If  
          End   With  
           
          objWord.PrintOut   0  
           
  EXITCODE:  
   
          objWordDoc.Close   0  
          objWord.Quit  
          Set   objWordDoc   =   Nothing  
          Set   objWord   =   Nothing  
          Exit   Sub  
                   
  OBJERROR:  
   
          If   Err   <>   429   And   Err   <>   4605   Then  
                  MsgBox   Str$(Err)   &   Error$  
                  objWord.Quit  
                  Set   objWord   =   Nothing  
                  Exit   Sub  
          Else  
                  Resume   Next  
          End   If  
   
  End   Sub  
 

NO.1   作者: lhfcsdn

在objWord.Visible   =   False之后加一句:  
   
   
  objWord.DisplayAlerts=wdAlertsNone

NO.2   作者: IamDeane

加个GOTO跳过去

NO.3   作者: crycoming

文件未找到的错误,是你应该事先写语句判断的  
  楼上的方法只是让它不显示错误框

NO.4   作者: crycoming

Dim   objWord   As   Word.Application  
          Dim   objWordDoc   As   Word.Document  
          Const   CLASSOBJECT   =   "Word.Application"  
           
          ---------------------------------  
          If   Dir(Command)   =   ""   Then  
                  文件不存在  
                  Exit   Sub  
          End   If  
          ---------------------------------  
           
           
          On   Error   GoTo   OBJERROR  
           
          Set   objWord   =   CreateObject("Word.Application")  
          objWord.Visible   =   False  
          -----------------------------------  
          关闭错误框  
          objWord.DisplayAlerts   =   wdAlertsNone  
          -----------------------------------


    摘要: 公司要做一个图片管理软件,要求能显示所有的图片文件的缩略图,浏览图片,和acdsee差不多,jpg、bmp、gif等都可以用image控间显示,psd和tif文件显示不了,哪位知道用什么控件可以实现这个功能,我用imgedit控件试了,它也只能显示tif文件,其他的都不能显示。急用,能解决送100分。 ......
» 本期热门文章:
· 热门栏目:
» 相关精选文章
» 其它相关:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE