Excel COM Addin

  • Thread starter Thread starter Jody L. Whitlock
  • Start date Start date
J

Jody L. Whitlock

I've gotten the COM Addin to work, my problem is this. I need to allow
the user to select a range of cells (All in the same column) and then
select my addin. My addin needs to pick up this range of cells and
then parse the value of each cell in this range. I have looked,
Googled, and thought I had it, but nadda.

Here's the code I have at the moment:

' *** BEGIN CUSTOM CODE. ***
Private Sub objCommandBarButton_Click(ByVal Ctrl As
CommandBarButton, _
ByRef CancelDefault As Boolean)

Dim WkBook As Excel._Workbook = applicationObject.Workbooks(1)
Dim WkSheet As Excel._Worksheet = WkBook.ActiveSheet
'Dim WkSheetNew As Excel._Worksheet =
applicationObject.Worksheets.Add(Nothing,
applicationObject.Worksheets(1))
Dim Range1 As Range = DirectCast(applicationObject.Selection,
Excel.Range)
Dim cell As Range
Dim PPS As Integer = 0

'WkSheetNew.Name = "SubTotals"
MsgBox(Range1.Address())
If Debugger.Launch() Then
For Each cell In Range1.Cells
Select Case CStr(cell.Value).Substring(0, 3)
Case Is = "PPS"
PPS += 1
End Select
Next
MsgBox("Found " & PPS & " Software Calls.")
Else
MsgBox("Couldn't Launch the Debugger")
End If
End Sub
' *** END CUSTOM CODE. ***


Thanks,
Jody W
 
Hi Jody,

Which is the exact problem? I have not tested with .NET code, but this
equivalen VBA macro works fine:

' ThisWorkBook file
Sub MyMacro()

Dim Range1 As Range
Dim cell As Range
Dim PPS As Integer

Set Range1 = Me.Application.Selection

PPS = 0

MsgBox (Range1.Address())

For Each cell In Range1.Cells
Select Case Mid$(CStr(cell.Value), 1, 3)
Case Is = "PPS"
PPS = PPS + 1
End Select
Next
MsgBox ("Found " & PPS & " Software Calls.")

End Sub

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
Carlos said:
Hi Jody,

Which is the exact problem? I have not tested with .NET code, but
this equivalen VBA macro works fine:

' ThisWorkBook file
Sub MyMacro()

Dim Range1 As Range
Dim cell As Range
Dim PPS As Integer

Set Range1 = Me.Application.Selection

PPS = 0

MsgBox (Range1.Address())

For Each cell In Range1.Cells
Select Case Mid$(CStr(cell.Value), 1, 3)
Case Is = "PPS"
PPS = PPS + 1
End Select
Next
MsgBox ("Found " & PPS & " Software Calls.")

End Sub

Sorry, I had to put that project on the backburner temporarily, but now
I'm back to it. I will give that a try and get back with you.

Thanks,
Jody W
 

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

Back
Top