Click here to Skip to main content
15,886,110 members
Home / Discussions / COM
   

COM

 
PinnedHOW TO ANSWER A QUESTION PinPopular
Chris Maunder16-Jul-09 3:09
cofounderChris Maunder16-Jul-09 3:09 
PinnedHow to get an answer to your question PinPopular
Chris Maunder16-Jul-09 3:05
cofounderChris Maunder16-Jul-09 3:05 
QuestionWhat remote work tools do you use with your team? Pin
JaleyRowe19-Mar-22 0:51
JaleyRowe19-Mar-22 0:51 
QuestionRe: What remote work tools do you use with your team? Pin
Richard MacCutchan19-Mar-22 2:27
mveRichard MacCutchan19-Mar-22 2:27 
GeneralHow to Wrap OLE Structured Storage Pin
Visual Herbert20-Feb-21 0:42
Visual Herbert20-Feb-21 0:42 
QuestionWin32 - Use COM object help Pin
Bret Stern8-Jan-21 5:39
Bret Stern8-Jan-21 5:39 
AnswerRe: Win32 - Use COM object help Pin
Richard MacCutchan8-Jan-21 6:30
mveRichard MacCutchan8-Jan-21 6:30 
QuestionHow to get header and footer value in MS Project file format(.mpp) using office interope (C#) Pin
Member 1481839713-Nov-20 5:38
Member 1481839713-Nov-20 5:38 
AnswerRe: How to get header and footer value in MS Project file format(.mpp) using office interope (C#) Pin
Gerry Schmitz13-Nov-20 9:49
mveGerry Schmitz13-Nov-20 9:49 
AnswerRe: How to get header and footer value in MS Project file format(.mpp) using office interope (C#) Pin
Richard MacCutchan13-Nov-20 22:06
mveRichard MacCutchan13-Nov-20 22:06 
Questioninterop Pin
lista25-Apr-19 7:00
lista25-Apr-19 7:00 
QuestionRe: interop Pin
Eddy Vluggen31-Mar-20 14:39
professionalEddy Vluggen31-Mar-20 14:39 
Questionkey match Pin
Member 141404154-Feb-19 23:24
Member 141404154-Feb-19 23:24 
AnswerRe: key match Pin
OriginalGriff4-Feb-19 23:28
mveOriginalGriff4-Feb-19 23:28 
QuestionObservation Pin
Richard Andrew x6415-Dec-18 8:22
professionalRichard Andrew x6415-Dec-18 8:22 
AnswerRe: Observation Pin
Mycroft Holmes5-Feb-19 14:35
professionalMycroft Holmes5-Feb-19 14:35 
QuestionConnect hsajet printer Pin
Member 1119728820-Oct-16 15:42
Member 1119728820-Oct-16 15:42 
AnswerRe: Connect hsajet printer Pin
Richard MacCutchan20-Oct-16 20:47
mveRichard MacCutchan20-Oct-16 20:47 
QuestionRegistration Free Com in Excel Pin
Member 1233692919-Oct-16 0:40
Member 1233692919-Oct-16 0:40 
AnswerRe: Registration Free Com in Excel Pin
Richard Deeming19-Oct-16 2:28
mveRichard Deeming19-Oct-16 2:28 
GeneralRe: Registration Free Com in Excel Pin
Member 1233692919-Oct-16 2:49
Member 1233692919-Oct-16 2:49 
GeneralRe: Registration Free Com in Excel Pin
Richard Deeming19-Oct-16 2:54
mveRichard Deeming19-Oct-16 2:54 
GeneralRe: Registration Free Com in Excel Pin
Member 1233692919-Oct-16 4:18
Member 1233692919-Oct-16 4:18 
Hello, in the article you linked in your post, there are two different GUIDs. What are the differences in the 2, and which ones should I be using?

Also, in the article to call the COM object he was able to reference the COM wrapper class built to expose the .NET calls to VBA in Visual Studio. I am trying to do this in Excel, where I can't simply reference the dll. Can somebody tell me how I can call COM objects in Excel? Here is my code for the COM Wrapper Class:

VB
Imports System
Imports System.Collections.Generic
Imports System.Runtime.InteropServices
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies

Namespace ExcelNXInterface

    <Guid("bbe0089d-a732-4743-922b-180b30006fa4"), _
  InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
    Public Interface _ExcelNXInterface
        <DispId(1)> Sub HighlightCompTag(ByRef tag As Long)
        <DispId(2)> Sub Echo(ByVal output As String)
    End Interface

    <ComVisible(True)>
    <Guid("975DC7E0-4596-4C42-9D0C-0601F86E3A1B"), _
     ClassInterface(ClassInterfaceType.None), _
     ProgId("ExcelNXInterface.Open")> Public Class ExcelNXInterface
        Implements _ExcelNXInterface

        Public _ExcelNXInterface

        Dim theSession As Session = Session.GetSession()
        Dim ufs As UFSession = UFSession.GetUFSession()

        Public Sub HighlightCompTag(ByRef tag As Long) Implements _ExcelNXInterface.HighlightCompTag

            'Cycles through component objects by tag in NX, and then when finding it, highlights it. 

            Try
                ufs.Disp.SetHighlight(tag, 1)
                Echo("Component(s) Highlighted...")
            Catch e As NXException
                Echo("NX Exception is: {0} " + e.Message)
            Catch e As Exception
                Echo("Exception is: {0} " & e.Message)
                Echo("DONE!" & vbLf)
            End Try

        End Sub

        Sub Echo(ByVal output As String) Implements _ExcelNXInterface.Echo

            theSession.ListingWindow.Open()
            theSession.ListingWindow.WriteLine(output)
            theSession.LogFile.WriteLine(output)

        End Sub

    End Class

End Namespace


Here is the manifest I built to reference in Excel:
XML
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly 
  manifestVersion="1.0" 
  xmlns="urn:schemas-microsoft-com:asm.v1" 
  xmlns:asmv1="urn:schemas-microsoft-com:asm.v1"
  xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <assemblyIdentity
    type="win32"
    version="1.0.0.0" 
    name="ExcelNXInterface"/>

  <clrClass
      clsid="{975DC7E0-4596-4C42-9D0C-0601F86E3A1B}"
      progid="ExcelNXInterface.Open"
      threadingModel="Both"
      name="ExcelNXInterface.Open">
  </clrClass>

  <file name = "ExcelNXInterface.dll"></file>   
</asmv1:assembly>


Here is the VBA code I am using to try and call the COM objects in Excel's IDE:

VB
Sub ExcelNX()

    Dim actCtx As Object
    Set actCtx = CreateObject("Microsoft.Windows.ActCtx")
    actCtx.Manifest = ThisWorkbook.Path & "\ExcelNXInterface.dll.manifest"

    Dim myNX As Object
    Set myNX = actCtx.CreateObject("ExcelNXInterface.Open")
    
    'Do stuff with object
   
End Sub


So far I am getting an error stating "Method 'CreateObject' of object IActCtx' failed" when it attemps to run this line of code:
<br />
Set myNX = actCtx.CreateObject("ExcelNXInterface.Open")<br />


The DLL I built to expose .NET calls to VBA, the Excel Workbook making the VBA calls and the Manifest are all in the same directory.

Any help or guidance is appreciated. Thank you.

modified 19-Oct-16 12:05pm.

GeneralRe: Registration Free Com in Excel Pin
Richard Deeming19-Oct-16 9:21
mveRichard Deeming19-Oct-16 9:21 
GeneralRe: Registration Free Com in Excel Pin
Member 1233692920-Oct-16 0:35
Member 1233692920-Oct-16 0:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.