Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Why does my AddIn do OnConnection() twice?

Hi

I have an addin application that takes a selection and strips out all
strings are not numbers, then it takes out strings which are too short of
too long and then displays the removed items in one listbox and the
remaining items in another listbox.

The code below seems to work ok but when it gets to the line where it calls
WorksheetFunction.IsText() it goes all the way back to the
AddinInstance_OnConnection method of the Connect.dsr. Why would it do this?

Another problem i am haveing with this code is that the first time i click
the button it works ok, the second time i click the button it acts as though
the selection is 'Nothing'.

I dont know if it is important to know in the context of this post but the
OnAction property of the button is set to the ProgID of the AddInInst passed
to the AddinInstance_OnConnection method.

Code is listed below.

Thanks
Ben

Friend Sub buttSendSMS_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
On Error GoTo err_ranges
Dim rngTotal As Excel.Range
Dim cell As Excel.Range

'set range to selected cells
Set rngTotal = oXL.Selection

On Error GoTo err_listboxes

'remove strings and short/long numbers
'everything else goes is assumed to be an ok phone number
For Each cell In rngTotal.Cells
If WorksheetFunction.IsText(cell.Value) Then
frmInvalidNumbers.lstText.AddItem cell.Value
ElseIf Len(cell.Value) < 8 Or Len(cell.Value) 15 Then
frmInvalidNumbers.lstText.AddItem cell.Value
Else
frmSendSMS.lstNumbers.AddItem cell.Value
End If
Next cell

frmInvalidNumbers.Show
rngTotal = Nothing
Exit Sub
err_ranges:
If Err.Number = 1004 Then
Resume Next
Else
MsgBox Err.Number & " " & Err.Description & ": occured when setting
ranges in clsAddIn.buttSendSMS_Click"
Resume Next
End If
err_listboxes:
MsgBox Err.Number & " " & Err.Description & ": occured adding when
spliting valid from in-invalid numbers"
Resume Next
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Why does my AddIn do OnConnection() twice?

Ben,

Are you referencing your forms directly? In your code I read references
to: frmInvalidNumbers and frmSendSMS

But I cannot determine if these are (Public) variables, or
direct references to the Project's components.

If it's the latter.. then that might be your problem.


Public ufINV as frmInvalidNumbers
Public ufSMS as frmSendSMS


On click
if ufINV IS nothing then
Set ufINV = new frmInvalidNumbers
else
ufinv.lstText.clear
endif

ufINV.LstText.additem etc..

ufINV.Show vbmodeless



keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Ben Crinion" wrote:

Hi

I have an addin application that takes a selection and strips out all
strings are not numbers, then it takes out strings which are too short
of too long and then displays the removed items in one listbox and the
remaining items in another listbox.

The code below seems to work ok but when it gets to the line where it
calls WorksheetFunction.IsText() it goes all the way back to the
AddinInstance_OnConnection method of the Connect.dsr. Why would it do
this?

Another problem i am haveing with this code is that the first time i
click the button it works ok, the second time i click the button it
acts as though the selection is 'Nothing'.

I dont know if it is important to know in the context of this post but
the OnAction property of the button is set to the ProgID of the
AddInInst passed to the AddinInstance_OnConnection method.

Code is listed below.

Thanks
Ben

Friend Sub buttSendSMS_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
On Error GoTo err_ranges
Dim rngTotal As Excel.Range
Dim cell As Excel.Range

'set range to selected cells
Set rngTotal = oXL.Selection

On Error GoTo err_listboxes

'remove strings and short/long numbers
'everything else goes is assumed to be an ok phone number
For Each cell In rngTotal.Cells
If WorksheetFunction.IsText(cell.Value) Then
frmInvalidNumbers.lstText.AddItem cell.Value
ElseIf Len(cell.Value) < 8 Or Len(cell.Value) 15 Then
frmInvalidNumbers.lstText.AddItem cell.Value
Else
frmSendSMS.lstNumbers.AddItem cell.Value
End If
Next cell

frmInvalidNumbers.Show
rngTotal = Nothing
Exit Sub
err_ranges:
If Err.Number = 1004 Then
Resume Next
Else
MsgBox Err.Number & " " & Err.Description & ": occured when
setting
ranges in clsAddIn.buttSendSMS_Click"
Resume Next
End If
err_listboxes:
MsgBox Err.Number & " " & Err.Description & ": occured adding when
spliting valid from in-invalid numbers"
Resume Next
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS VB addin err DL Excel Worksheet Functions 0 May 15th 07 05:22 PM
Addin Help alexm999 Excel Discussion (Misc queries) 4 July 25th 06 08:27 PM
COM Addin in C# Hailiang Excel Programming 0 July 15th 04 08:09 AM
Remove Excel AddIn from AddIn List !! Help carl Excel Programming 2 December 8th 03 03:36 PM
Addin Peter Pantus Excel Programming 4 October 11th 03 07:40 PM


All times are GMT +1. The time now is 05:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"