Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

COM access

I was just wondering for VB.net what I have to declare a function as to let outside applications use it. Right now, this is my function:

        Sub SearchReplace()
            ThisApplication.Documents.Open("C:\reminder.doc")
            With ThisApplication.Selection.Find
                .ClearFormatting()
                .Text = search_text
                With .Replacement
                    .ClearFormatting()
                    .Text = replace_text
                End With
                .Execute(Replace:=MyINTERP.WdReplace.wdReplaceAll)
            End With
        End Sub

Just basically is a search and replace function. I have the following to set the actual variables:

        Public Property searchText()
            Get
                Return search_text
            End Get
            Set(ByVal Value)
                search_text = Value
            End Set
        End Property
        Public Property replaceText()
            Get
                Return replace_text
            End Get
            Set(ByVal Value)
                replace_text = Value
            End Set
        End Property

Now, I can set the search_text and replace_text variables prefectly via COM, but when I try to do this:

myobj.SearchReplace();

It throws a nasty error my way. Should I be declaring it something other than a Subroutine?
0
drakkarnoir
Asked:
drakkarnoir
1 Solution
 
realraelCommented:

try making your sub public:

Public Sub SearchReplace()

here's some reference: http://support.microsoft.com/default.aspx?scid=kb;en-us;307210&Product=vbNET#6

let me know how it goes.

- rael
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now