Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling managed code from Access 2003
    primarykey
    data
    text
    <p>I have cross posted on <a href="http://access-programmers.co.uk/forums/showthread.php?t=144006" rel="nofollow noreferrer">access-programmers.co.uk</a></p> <p>Please post responses on that forum is possible..</p> <p>I have compiled a dll in c# 3.5.. where I set the solution properties to register the build for COM interop.</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace SBG_TestWithVBA { [ClassInterface(ClassInterfaceType.AutoDual)] public class TestHello { [ComVisible(true)] public string SayHello(string name) { string message = "Hello " + name; return message; } public string HelloWorld() { string message = "Hello World!"; return message; } } } </code></pre> <p>I have then registered the assembly and tlb file using</p> <blockquote> <p>"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe" "\sbgfs01\users\Vincent Pirolli\My Docs\Visual Studio 2008\Projects\TestWithVBA\TestWithVBA\bin\Release\SBG_TestWithVBA.dll" /tlb: "\sbgfs01\users\Vincent Pirolli\My Docs\Visual Studio 2008\Projects\TestWithVBA\TestWithVBA\bin\Release\SBG_TestWithVBA.tlb"</p> </blockquote> <p>I then add the tlb file within vba from the tools>references menu..</p> <p>and my VBA code is as follows:</p> <pre><code>Sub test() Dim f As SBG_TestWithVBA Set f = New SBG_TestWithVBA f.HelloWorld End Sub </code></pre> <p>I get the following error even though Intellisense works within the VBA editor: <strong>"Automation error The system cannot find the file specified."</strong></p> <p>Anyone got any ideas? I have the articles in the previous posts but I cannot find the solution.</p> <hr> <p>ok, this is really annoying me now..</p> <p>i've managed to get this to work.. but i dont understand why..</p> <p>In solution properties within visual studio.. on the Build tab i set 'Register for COM interop' to true, and within 'Application>Assembly Information', i set 'Make assembly COM-Visible' = TRUE..</p> <p>I have the VS project files in a shared drive. Now if i set the build location to the bin folder on the share drive, under my project files, when i call from VBA it doesnt work.. However, if i set the build folder to a folder on my local C Drive, then it works fine when calling from VBA..</p> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload