Accessing a worksheet from a VB Add-in ( not VBA )

C

Chris Houston

Hi,

I have written a add-in using VBA that I am now trying to convert to a VB
addin using Visual Studio.

I have the add-in working, and my code adds menu items within Excel, when
these are clicked they pop
up windows forms.

My problem is from these forms I am trying to access the Worksheets, and I
seem unable to work out
how to access these objects? In the form_Activated subroutine I am trying to
copy all the currently selected
cells into an array.

The VBA code I am trying to replicate within the VB Addin is:

Dim oCell As Range
Dim cnt As Integer, a As Integer

cnt = -1

FromAddress.Text = ""

MessageBox.Text = ""

For Each oCell In Selection

ReDim Preserve NumberToSendToo(cnt + 1) ' This is the array to store the
valid numbers

If ValidateNumber(oCell.Value) Then ' This function checks that the cells
contain valid (phone) numbers

cnt = cnt + 1

NumberToSendToo(cnt) = Convert2InternationalNumber(oCell.Value) ' This
function converts the numbers to the international format.

End If

Next

If (cnt + 1) > 0 Then

If (cnt + 1) = 1 Then

ValidNumberLabel.Text = "1 Valid Number Found" ' This is a label on the
form used to show the number of valid numbers found

Else

ValidNumberLabel.Text = CStr(cnt + 1) + " Valid Numbers Found"

End If

Else

ValidNumberLabel.Text = "No Valid Numbers Selected"

Send_Command.Enabled = False

End If

If you can help you'll make my last few hours of frustration not feel quite
so bad!

Thanks in advance,


Chris
 

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