Manipulate a file in code (VB.NET) without executing the file's macros

前端 未结 2 2008
误落风尘
误落风尘 2021-01-24 06:48

I have an Excel file that has a bunch of VBA and macro code in it. When I open the file in Excel I can choose not to \'enable\' them - so the values in the fields all stay as t

2条回答
  •  灰色年华
    2021-01-24 07:19

    Is ADO any use to you? I can only give a script example, i'm afraid.

    strLinkFile = "C:\Docs\LTD.xls"
    
    Set cn = CreateObject("ADODB.Connection")
    cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=" & strLinkFile & ";" & _
           "Extended Properties=""Excel 8.0;HDR=YES;"""
    
    Set rs = CreateObject("ADODB.Recordset")
    rs.Open "Select * from [Sheet1$A1:B5]", cn, adOpenStatic 
    

提交回复
热议问题