Manipulate a file in code (VB.NET) without executing file macros
I have an Excel file that has a bunch of VBA and macros. When I open the file in Excel, I can choose not to include them, so the values in the fields remain as they were when they were last saved. I need to manipulate the values since they were last saved - so I don't want macros (which look at the current date and update values respectively) to run.
When I open it through our network code:
Dim oxlRep As Excel.Application
Dim oWBRep As Excel.Workbook
Dim oSheetRep As Excel.Worksheet
Dim oRngRep As Excel.Range
oxlRep.Open(path)
vb code is executed - reset values. I was looking for a way to open it without macros or in safe mode where macros don't run. If I just double-click the file and don't want to enable macros, all the values are where I want them.
We usually run this code for a month when the files are created, so we didn't see this issue in 3 or 4 years when it worked. Now I need to go back to some old files and run the archive code ...
Anyone have a suggestion?
source to share
Is ADO being used for you? I can only give an example script, 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
source to share