아래의 Excel 매크로는 Excel의 특정 행 (행 2)에서 작동하도록 작성되었습니다. 2 행이 아닌 내가 선택한 행에 적용하고 싶습니다. 어떻게 적용해야하는지 알고 있습니까? 나는 이것을 위해 쓰여졌으며 VBA 코딩을 모른다.
Sub test()
Set ie = CreateObject("internetexplorer.application")
ie.Navigate "http://www.fedex.com/us/"
While ie.Busy Or ie.ReadyState <> 4: DoEvents: Wend
ie.Visible = 1
Set doc = ie.document
On Error Resume Next
With doc
.getElementsByname("username").Item(0).Value = "Username"
.getElementsByname("password").Item(0).Focus
.getElementsByname("password").Item(0).Value = "Password"
.getElementsByname("startpage").Item(0).selectedindex = 1
.getElementsByname("login").Item(0).Click
While ie.Busy Or ie.ReadyState <> 4: DoEvents: Wend
Application.Wait (Now + TimeValue("00:00:04"))
Set doc = ie.document
doc.getElementsByname("toData.addressData.contactName").Item(0).Value
= Range("L2")
doc.getElementsByname("toData.addressData.addressLine1").Item(0).Value
= Range("M2")
doc.getElementsByname("toData.addressData.city").Item(0).Value = Range("N2")
doc.getElementsByname("toData.addressData.zipPostalCode").Item(0).Value
= Range("P2")
doc.getElementsByname("toData.addressData.phoneNumber").Item(0).Value
= Range("S2")
doc.getElementsByname("psdData.mpsRowDataList[0].weight").Item(0).Value
= Range("F2")
doc.all("psdData.packageType").Value = "Your Packaging"
Call ie.document.parentWindow.execScript("psdHandler_onShipPackageTypeChange(""IS3_GSV="")", "JavaScript")
ie.document.getElementsByname("psdData.mpsRowDataList[0].mpsDimensionSelect").Item(0).Item(1).Selected
= True
Call ie.document.parentWindow.execScript("psdHandler_onChangeDimensions()", "JavaScript")
ie.document.getElementsByname("psdData.mpsRowDataList[0].mpsLength").Item(0).Value
= Range("g2")
ie.document.getElementsByname("psdData.mpsRowDataList[0].mpsWidth").Item(0).Value
= Range("h2")
ie.document.getElementsByname("psdData.mpsRowDataList[0].mpsHeight").Item(0).Value
= Range("i2")
.getElementbyid("module.rating._headerButtons").Click
ie.document.getElementbyid("rating.calculateRate").Click
End With
Set doc = Nothing Set ie = Nothing
End Sub