macro to add button to a spreadsheet cell
Hi folks,
I'm pleased to see such a straightforward post about this topic...
However, when I implement this method I get an, "Argument not
optional" message box. I'll give you my code:
Sub AddButtonandMacroToSheet()
Range("I2").Select
ActiveSheet.Buttons.Add(ActiveCell.Left, _
ActiveCell.Top, _
ActiveCell.Width, _
ActiveCell.Height).Select
Selection.OnAction = "GetPPID"
End Sub
Here's the code for my macro:
Function GetPPID(PPID) As String
Const URL As String = _
"https://report.converge.com/dell/internal/check_battery.php?
ppid="
Const FRAG1 As String = "'green'"
Const FRAG2 As String = "</FONT"
Dim msxml As Object
Dim rV, tmp, pos1, pos2
rV = ""
If PPID < "" Then
Set msxml = CreateObject("Microsoft.XMLHTTP")
msxml.Open "Get", URL & PPID, False
msxml.send
tmp = msxml.responseText
pos1 = InStr(tmp, FRAG1)
pos2 = InStr(tmp, FRAG2)
' If pos1 0 And pos2 0 Then
' rV = Left(tmp, pos2 - 1)
' rV = Right(rV, Len(rV) - (pos1 + Len(FRAG2)))
' End If
rV = tmp ' to be parsed later
Set msxml = Nothing
End If
GetPPID = Right(Left(rV, 83), 58)
' example of return string to be parsed
' [center][BR][BR][BR][BR][FONT COLOR='green']
' PPID: THE-BARCODE-HE KEEP AT CONVERGE![/font][BR]
' [BR][HR][BR][BR][FORM ACTION = 'check_battery.php']PPID:
' [INPUT TYPE='text' NAME = 'ppid'][BR][BR][INPUT TYPE='SUBMIT'
' VALUE = ' SUBMIT '][/FORM]
End Function
|