and ask if the new name is acceptable.
pintRenameFail = True
Do While pintRenameFail
pintRenameFail = False
pintReturn = MsgBox( _
“Rename “ & _
DLookup(“[ControlTypeName]”, _
“zLNCtblControlType”, _
“[ControlType] = “ & ctl.ControlType) _
& “ control currently named “ _
& pstrOldCtlName & vbCrLf & _
“(control source: “ & strControlSource & “) “ _
& “to” & vbCrLf & pstrNewCtlName & “?”, _
vbYesNo + vbQuestion + vbDefaultButton1, _
“Rename control”)
If the user clicks the Yes button, rename the control.
If pintReturn = vbYes Then
If blnTag = True Then
ctl.Tag = ctl.ControlName
End If
ctl.ControlName = pstrNewCtlName
Otherwise, pop up an input box to edit the name.
ElseIf pintReturn = vbNo Then
pstrNewCtlName = _
InputBox(“Modify new control name”, _
“Rename control”, pstrNewCtlName)
ctl.ControlName = pstrNewCtlName
End If
Loop
ErrorHandlerExit:
Exit Function
ErrorHandler:
If the proposed control name is already in use, return to the renaming dialog.
pintRenameFail = True
If Err.Number = 2104 Then
MsgBox “There is another control named “ & _
pstrNewCtlName & “; please try again”, , _
“Control Name Used”
pstrNewCtlName = pstrNewCtlName & “1”
Creating COM Add-ins with Visual Basic 6 13