CreateComObjectFromProgId
Option Strict Off
Public Sub Main() Dim app As Object Try app = CreateComObjectFromProgId("Excel.Application") If app IsNot Nothing Then Dim wbk As Object = app.Workbooks.Open("C:\Data\ExcelTest.xls") If wbk IsNot Nothing Then Dim sheet As Object = wbk.Sheets("Sheet3") If sheet IsNot Nothing Then sheet.Visible = 0 '0 = hidden wbk.Save() app.Quit() End If End If End If Catch ex As Exception app.Quit() End Try Dts.TaskResult = Dts.Results.Success End Sub Private Function CreateComObjectFromProgId(ByVal progId As String) As Object Dim oType As Type = Type.GetTypeFromProgID(progId) If oType Is Nothing Then Return Nothing Else Return Activator.CreateInstance(oType) End If End Function
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.