返回列表 上一主題 發帖

[發問] 問一個修改欄位的問題 (hugh0620 解決了我的問題,感謝)

回復 1# av8d

    程式碼這樣修改其實沒錯~
    樓主要在"E1"欄位輸入資料~ 就可以執行~
學習才能提升自己

TOP

本帖最後由 hugh0620 於 2012-2-15 12:03 編輯

回復 3# av8d


    樓主試著用下面的方式來設定~
    這樣只要同一列的B或C欄都有資料就可以被執行~
    例B1或C1兩個欄位都有資料點選C1或B1都可以被執行
        B:出發地
        C:目標地
  1. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  2.     If Target.Column = 2 And Target <> "" Then
  3.         If Target.Offset(0, 1) <> "" Then
  4.             Cancel = True
  5.             With CreateObject("InternetExplorer.Application")
  6.                 .Navigate "http://maps.google.com.tw/"
  7.                 Do While .Busy Or .ReadyState <> 4
  8.                     DoEvents
  9.                 Loop
  10.                 .Document.all("d_d").innerText = Target                        'A點~ 出發地
  11.                 .Document.all("d_daddr").innerText = Target.Offset(0, 1)       'B點~ 目標地
  12.                 .Document.all("d_sub").Click
  13.                 .Visible = True
  14.             End With
  15.         End If
  16.     ElseIf Target.Column = 3 And Target <> "" Then
  17.         If Target.Offset(0, -1) <> "" Then
  18.             Cancel = True
  19.             With CreateObject("InternetExplorer.Application")
  20.                 .Navigate "http://maps.google.com.tw/"
  21.                 Do While .Busy Or .ReadyState <> 4
  22.                     DoEvents
  23.                 Loop
  24.                 .Document.all("d_d").innerText = Target.Offset(0, -1)          'A點~ 出發地
  25.                 .Document.all("d_daddr").innerText = Target                    'B點~ 目標地
  26.                 .Document.all("d_sub").Click
  27.                 .Visible = True
  28.             End With
  29.         End If
  30.    
  31.     End If
  32. End Sub
複製代碼
學習才能提升自己

TOP

回復 3# av8d


    提供一個修改的檔案給您參考
    呼叫地圖.rar (6.75 KB)
學習才能提升自己

TOP

        靜思自在 : 稻穗結得越飽滿,越會往下垂,一個人越有成就,就要越有謙沖的胸襟。
返回列表 上一主題