how to add SaveDialog to my custom VB class Lib (dll) for com use?

G

Guest

Hello,

I created a basic class library (dll, tlb) in VB2005 for com use in MS
Access. I added a form to the class library because eventually, I want to
use a SaveDialog control with this dll. I compiled the class to be com
visible and register for com (in the compile tab). The build went
successfully, and I can invoke the class from an MS Access code module. Upon
invoking the dll, you can see the dll form for a split second, then it goes
to the background, although the form's icon is in the windows status bar (or
whatever it's called - the thing with all the open app icons). So I can
bring the form to the front by clicking its icon. Eventually, the dll is
going to copy data from Access to Excel using ADO.net. How can I implement
the SaveDialog control/class in my dll? Here is the code for the test dll
which works - except that the form goes to the background:

------------------------------------------------------------------------------------
Imports System.Runtime.InteropServices

<Guid("A87CC055-687F-4116-AC3A-71D3B2447A09"), _
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)> _
Public Interface _IHelloWorld
<DispId(1)> Sub HelloWorld(ByVal s1 As String)
<DispId(2)> Sub Openfrm(ByVal s1 As String)
End Interface

<Guid("E96A973D-A533-4BC0-B57A-6C52409F6BBE"), _
ClassInterface(ClassInterfaceType.None), _
ProgId("testDLL.clsTestDLL")> _
Public Class clsTestDLL Implements _IHelloWorld

Public Sub HelloWorld(ByVal s1 As String) Implements _IHelloWorld.HelloWorld
MsgBox("Hello, World from my test! -- " & s1)
End Sub

Public Sub Openfrm(ByVal s1 As String) Implements _IHelloWorld.Openfrm
Dim frm As New Form1
frm.Text = s1
frm.Show()
frm.BringToFront()
End Sub

End Class

----------------------------------------------------------------------------

and here is my code for the GUID generator for the Interface. I invoke the
new GUID string from a regular app with a straight forward button on a form

Dim guidString As String = String.Format("Guid(""{0}"")",
Guid.NewGuid().ToString().ToUpper())

'-- Copy string GUID to clipboard
Clipboard.SetText(guidString)


Is there a way I could invoke the SaveDialog control/class in my dll without
using a form?


Thanks,
Rich
 
G

Guest

Well, I went ahead and added a SaveFileDialog to the form and was able to
invoke it from Access, and it actually worked fine. For SaveDialog stayed in
from because I opened it ShowDialog, and I don't show the Form - just the
SaveFileDialog.

If frm.SaveDlg1.ShowDialog = Windows.Forms.DialogResult.OK Then
s1 = frm.SaveDlg1.FileName
MsgBox(s1)
End If

I am sort of happy now because I can move on with the project, but I am sure
there is a way to use a SaveFileDialog class without the overhead of a form.
Would this be more efficient if I used the SaveFileDialog without the form,
or is it better to keep it simple by using the SaveFileDialog with the form?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top