Justin Ross
New member
- Joined
- Sep 18, 2014
- Messages
- 3
- Programming Experience
- 1-3
Hello All,
I am trying to develop a dll file using Visual Studio 2013 Ultimate for automating Excel.
While trying to do so, I receive a big error message while declaring object for workbook.
Request you to provide some piece of code to declare object for Excel application and Excel workbook and then to get the count of excel workbooks opened.
Below is the sample code.
Below is the error message i receive at the line of
Dim wb As New Microsoft.Office.Interop.Excel.Workbook
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PDUNZDLL.dll
Additional information: Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."
Thanks in Anticipation
I am trying to develop a dll file using Visual Studio 2013 Ultimate for automating Excel.
While trying to do so, I receive a big error message while declaring object for workbook.
Request you to provide some piece of code to declare object for Excel application and Excel workbook and then to get the count of excel workbooks opened.
Below is the sample code.
VB.NET:
Imports System.Runtime.InteropServices
Imports System.Text
Imports Microsoft.Win32
Public Class ATOM
<DllImport("user32.dll", SetLastError:=True)> _
Private Shared Function GetWindowThreadProcessId(ByVal hwnd As IntPtr, _
ByRef lpdwProcessId As Integer) As Integer
End Function
Public Function Click()
Dim ExcelApp As New Microsoft.Office.Interop.Excel.Application
Dim diffexcelapp As New Microsoft.Office.Interop.Excel.Application
Dim wb As New Microsoft.Office.Interop.Excel.Workbook
MsgBox(diffexcelapp.Workbooks.Count)
MsgBox(ExcelApp.Workbooks.Count)
End Function
End Class
Below is the error message i receive at the line of
Dim wb As New Microsoft.Office.Interop.Excel.Workbook
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in PDUNZDLL.dll
Additional information: Retrieving the COM class factory for component with CLSID {00020819-0000-0000-C000-000000000046} failed due to the following error: 80040154."
Thanks in Anticipation