By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,798 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

Excel COM Addin

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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

"Jody L. Whitlock" <ti*************@hotmail.com> escribió en el mensaje
news:eq**************@TK2MSFTNGP14.phx.gbl...
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

Nov 21 '05 #2

P: n/a
Carlos J. Quintero [.NET MVP] wrote:
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
Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.