2016-09-27 8 views
1

IDまたは名前のないボタンをクリックしようとしています。私は、タブを使用してみましたが、それはうまくいきませんでした、と私は、次のコードを試してみましたが、それは何もしません。IE上で使用するvbaのidを付けないボタンをクリック

Set tags = Ie.document.getElementsByTagName("button") 
For Each tagx In tags 
    If tagx.Value = "Save" Then 
     tagx.onclick 
     Exit For 
    End If 
Next 

そしてここでは、HTMLマークアップです:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"> 
    <div class="ui-dialog-buttonset"> 
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Cancel</span></button> 
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Save</span></button> 
    </div> 
</div> 

答えて

0

tagx.Value常に空です。 HTMLボタンの値の属性情報hereを確認します。

ボタンを使用して、保存ボタンを見つけ、それにClickメソッドを呼び出すことがtagx.innerTextをチェックすることができるように、テキスト保存またはSpanはその中をキャンセル持っているようです。

Set tags = ie.document.getElementsByTagName("button") 
For Each tagx In tags 
    If tagx.innerText = "Save" Then 
     tagx.Click 
     Exit For 
    End If 
Next 
+0

ディー、あなたの作品は完璧なものです –

+0

@gpmn私はそれが助けて嬉しいです:)。答えを受け入れるようにマークしてください。 – dee

関連する問題