我现在用VBA写了一个小的程序,功能是:点击OK按钮可以打开一系列的Excel文件(后缀名为.xls),并读出每一个文件的内容,写入另一个Excel文件中.
现在这个功能基本实现了,只是在打开这一系列Excel文件(后缀名为.xls)时是不是应该有一个属性可以控制它为隐形打开,即文件是打开了并能取出数据但是不要求操作者看到文件的真正打开.
我想问的就是有没有这样一个属性,如果有是哪一个?
我找了好久都没找到.

解决方案 »

  1.   


    首先谢谢这位的帮忙了,很感谢哦!
    用Application.Visible道是能实现那个要求,可是它不仅仅是关闭了要打开的一系列Excel文件,连我要写入信息的那个Excel文件也关了,要查看结果还得要重新打开,这样很麻烦,而且不知道的还以为这样出错了,有没有更好的方法呢?
      

  2.   

    要创建另外一个Excel对象,然后把这个对象的visible置成false,再用这个对象去打开一系列的excel,这样才可与被写的文件分开。
      

  3.   

    worksheet有visible属性的,所用按文件隐藏应该不是问题。
      

  4.   

    Retrieving a value from a closed workbook
    VBA does not include a method to retrieve a value from a closed workbook file. You can, however, take advantage of Excel's ability to work with linked files. This section contains a custom VBA function (GetValue, which follows) that retrieves a value from a closed workbook. It does so by calling an XLM macro, which is an old-style macro used in versions prior to Excel 5. Fortunately, Excel still supports this old macro system.Private Function GetValue(path, file, sheet, ref)
    '   Retrieves a value from a closed workbook
        Dim arg As String'   Make sure the file exists
        If Right(path, 1) <> "\" Then path = path & "\"
        If Dir(path & file) = "" Then
            GetValue = "File Not Found"
            Exit Function
    End If
    '   Create the argument
        arg = "'" & path & "[" & file & "]" & sheet & "'!" & _
            Range(ref).Range("A1").Address(, , xlR1C1)'   Execute an XLM macro
        GetValue = ExecuteExcel4Macro(arg)
    End Function