I'm designing a program that runs a Excel query file (.dqy), edits the information by adding mathematical columns, and saves the Excel file. That all works, however I would like to unlink the data connection to the saved file, and I am unsure on how to do that without using sendkey commands (which I would rather not do if preventable). Any help would be appreciated.
VB.NET:
appXL = CreateObject("Excel.Application")
appXL.Visible = True
' Open a new workbook.
wbXl = appXL.Workbooks.Open("C:\Employees.dqy")
shXL = wbXl.ActiveSheet
' Add table headers going cell by cell.
shXL.Cells(1, 5).Value = "Math Test"
' Fill C2:C6 with a relative formula (=A2 & " " & B2).
raXL = shXL.Range("E2", "E6")
raXL.Formula = "=A2 + B2"
' AutoFit columns A:D.
raXL = shXL.Range("A1", "E1")
raXL.EntireColumn.AutoFit()
'Make sure Excel is visible and give the user control
'of Excel's lifetime.
appXL.Visible = True
appXL.UserControl = True
' Release object references.
'NEED CODE HERE TO UNLINK DATA BEFORE SAVING.
wbXl.SaveAs("C:\TEST.xlsx")
raXL = Nothing
shXL = Nothing
wbXl = Nothing
appXL.Quit()
appXL = Nothing
Exit Sub