Question Query in Developing adding/dll file for excel automation

Justin Ross

New member
Joined
Sep 18, 2014
Messages
3
Programming Experience
1-3
Hello All,

First post in VBdotforums!!!!

I have created a Excel macro(using VBA) which performs specific functions. Due to security reasons i have decided to create my functions in dll and distribute.

When i try to create a dll/class library in VS2013, i receive the below error in line

"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."

Basically what i have done is created a application with a vb form along with a button. On button click, it will call a function("Click" function) inside my dll.

This is my dll name PDUNZDLL.dll

Below is my Dll 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

If i create an object for excel and I get the count of excel workbooks opened it would be a good start for me to convert my Excel Macro (VBA) to dll.
 

Latest posts

Back
Top