zoukankan      html  css  js  c++  java
  • win 7 下 UserAccounts.CommonDialog 出错的解决方式

    Dim strExcelFilePath,objDialog,tfile
    Set objDialog = CreateObject("UserAccounts.CommonDialog")
    objDialog.Filter = "Excel 2003|*.xls|Excel 2007|*.xlsx"
    objDialog.InitialDir = CreateObject( "WScript.Shell" ).SpecialFolders( "MyDocuments" )
    tfile=objDialog.ShowOpen
    If tfile Then 
    strExcelFilePath = objDialog.FileName

          ...... 

    很正常的一段代码,但是在win 7 下就出错了,网上找了个解决方式:

     1 Function ChooseFile()
     2      Dim Result
     3      Result = ""
     4      Dim IE : Set IE = CreateObject("InternetExplorer.Application")
     5      With IE
     6          .Visible = False
     7          .Navigate("about:blank")
     8          Do Until .ReadyState = 4 : Loop
     9          With .Document
    10              .Write "<html><body><input id='f' type='file'></body></html>"
    11              With .All.f
    12                  .Focus
    13                  .Click
    14                  Result = .Value
    15              End With
    16          End With
    17          .Quit
    18      End With
    19      Set IE = Nothing
    20     ChooseFile = Result
    21 End Function
  • 相关阅读:
    1052 卖个萌 (20 分)
    1046 划拳 (15 分)
    1051 复数乘法 (15 分)
    1042 字符统计 (20 分)哈希
    1041 考试座位号 (15 分)哈希
    1061 判断题 (15 分)
    1093 字符串A+B (20 分)简单哈希
    Hibernate框架
    SVN的安装与介绍
    easyUI的简单操作
  • 原文地址:https://www.cnblogs.com/abinxm/p/1762028.html
Copyright © 2011-2022 走看看