Hi Guys / Gals,
I've been trying to get a function that checks the warranty details from Hp/Compaq, but I keep getting strange errors (such as Invalid procedure call or argument: 'Mid') or getting status:%20%20-?Model=zzzxzxzx&sn=cvcvxvxs in the status bar??
I don't quite know how to incorporate the funuction into a search. Just hoped one of you may be able to helpl me out.
Thanks in advance.
The function is below:
I've been trying to get a function that checks the warranty details from Hp/Compaq, but I keep getting strange errors (such as Invalid procedure call or argument: 'Mid') or getting status:%20%20-?Model=zzzxzxzx&sn=cvcvxvxs in the status bar??
I don't quite know how to incorporate the funuction into a search. Just hoped one of you may be able to helpl me out.
Thanks in advance.
The function is below:
Code:
function WarrantyCheck(serialnumber, model)
'on Error Resume Next
pn = ""
if Len(trim(serialnumber)) <= 10 Then
pn = Whatstheproductnumber(model)
End if
Dim hugeArr, minfo
Dim returnStr, strInfo
'minfo= split(sn, ",")
sn = serialnumber
url="[URL unfurl="true"]http://h20000.www2.hp.com/bizsupport/TechSupport/WarrantyResults.jsp?prodSeriesId=316664&prodTypeId=321957&sn="[/URL] & sn & "&pn=" & pn & "&country=US&nickname=&nickname2=&source=single&x=38&y=13&locale=en_US"
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
Call objHTTP.Open("GET", url, FALSE)
objHTTP.Send
returnStr = objHTTP.ResponseText
hugeArr = Split(returnStr,"OVERALL START DATE")
'---[ info starts at hugeArr(1)
StrInfo = Mid(hugeArr(1),1,1100)
'---[ warranty start Date
startdate = InStr(StrInfo, "<TD width=350>")
warranty_start_date = Mid(StrInfo, startdate + 14,11)
'---[ warranty status
status = InStr(strInfo, "<TD><B><FONT color")
wtstatus = Mid(strInfo,status+18,50)
tmp1 = InStr(wtstatus,">") + 1
tmp2 = InStr(wtstatus,"<")
warranty_status = Mid(wtstatus,tmp1,tmp2-tmp1)
'---[ warranty End Date
endd = InStr(strInfo, "<B>End Date</B>")
tmp = Mid(strInfo,endd,100)
tmp1 = InStr(tmp,"<TD width=350>") + 14
warranty_end_date = trim(Mid(tmp,tmp1,15))
w_stat = IIF(warranty_status="Expired", "Ended on: ", "Ends on: ")
WarrantyCheck = "Status: " & warranty_status & " - " & w_stat & Replace(warranty_end_date,Chr(10),"")
End function
function Whatstheproductnumber(modelin)
' Evo N610c 470050-020 = 470050-20
' HP Compaq nc6000 (DH913U#ABA) = DH913U#ABA
' Evo N610c 279941-999 = 279941-999
' HP d530 CMT(DG767A) = DG767A
' Compaq Deskpro = DESKPRO
modelin = trim(Replace(modelin,"("," "))
modelin = trim(Replace(modelin,")"," "))
modelin = Mid(modelin, InStrRev(modelin," "))
Whatstheproductnumber= modelin
End function