2016-08-16 13 views
0

私は、次のWebサイトhttp://www.isincodes.net/convert-cusip-to-isin.phpからvba(& internetexplorerオブジェクト)を使用して、CSUIPをISIN(これらは財務セキュリティ固有の識別コードです)に変換しています。私はこれまで(以下の順序で)これをVBAコードを作成しているVBA簡単な解析

:InputBox関数に 1.米国/ CAのドロップダウンボックスを操作する 2.入力私のCUSIP 3.クリック「隠密」ボタン

Sub cusip_is2() 

'declare variables 
Set objie = CreateObject("internetExplorer.Application") 

objie.Visible = True 

'go to website 
objie.navigate ("http://www.isincodes.net/convert-cusip-to-isin.php") 
Do 
DoEvents 
Loop Until objie.readyState = 4 

'input the CA in the country ID step1 
objie.document.getelementbyID("country").Value = "CA" 

'input 912796HQ5 in text box as desired CUSIP to convert 
objie.document.getelementbyID("appendedInputButton").Value = "912796HQ5" 


'press the button to convert 
Set ElementCol = objie.document.getElementsByTagName("button") 
For Each btnInput In ElementCol 
    btnInput.Click 
Next btnInput 

'wait until the pages loads (not sure if I need this) 
Do 
DoEvents 
Loop Until objie.readyState = 4 

'added extra few seconds incase HMTL document is updating 
Application.Wait Now + TimeSerial(0, 0, 1) 

'created userform to look at the data to see if I can find the converted CUSIP - WHICH I CANNOT (HELPPPPP!!!!) 
Userfrom_Web_Code.Textbox_Webform.Text = objie.body.innerText 
Userfrom_Web_Code.Show 


'clean up and try again for the next failure LOL 
objie.Quit 
Set objie = Nothing 
End Sub 

私の研究から、私はソースコードを取得し続けていることを知っていますが、私はDOMが欲しい、これが私が問題を抱えている場所です。国の "CA"とCUSIP "912796HQ5"を入力したら、ウェブサイトのソースコードの抜粋を見てください。結果のidタグには何も含まれていません。私は「DOM」に私を取る検査要素をチェックするとき

<p>Enter a CUSIP and a correct ISIN will be calculated for you, if possible:</p> 
        <form class="form-inline"> 
         <div class="input-append"> 
          <select id="country" style="width:60px;"> 
           <option value="CA">CA</option> 
           <option value="US" selected>US</option> 
          </select> 
          <input type="text" maxlength="9" class="span3" id="appendedInputButton"> 
          <button type="button" class="btn">Convert</button> 
         </div> 
        </form> 

        <div id="results"></div> 

        <br><br> 
            </div> 

       <div class="span4"> 
        <h4>What is a CUSIP?</h4> 
        <p>A CUSIP is a 9-character alphanumeric code which identifies a North American financial security.</p> 
        <p> 
         A CUSIP consists of three parts:<br> 
         &#8226; A six-character issuer code<br> 
         &#8226; A two-character issue number<br> 
         &#8226; A single check digit.<br><br> 
         For example: 780259206 (Royal Dutch Shell-A) 
        </p> 

逆に、私は、ID結果の下にこれを見ることができます。

<div id="results" style="display: block;"><br> 
 
<b>Strict Standards</b>: Non-static method Validate_CUSIP::validate() should not be called statically in <b>/home/isincode/public_html/action/c.php</b> on line <b>15</b><br> 
 
<p class="text-success"><strong>Correct ISIN: CA912796HQ58</strong></p></div>

誰も私はVBAでこの問題を解決する助けてください。

vba/excelでアルゴリズムを自分で作成して、CUSIPをISINに変換することはできますが、このプロジェクトをVBAで解析して解析したいと思います。私はコーディングにも非常に新しく、親切にして、あなたが提案したものすべてを説明してください。

答えて

1

次エディットがあなたに合うかどうかを確認してください:

.... 
.... 
'added extra few seconds incase HMTL document is updated 
Application.Wait Now + TimeSerial(0, 0, 2) 

Dim ISIN As String 
ISIN = Right(objie.document.getelementbyID("results").innerText,12) 'the 12 rightmost characters 
Debug.Print "ISIN you are looking for is: " & ISIN 
.... 

編集

+0

はCarmelidねえ、私の自宅のコンピュータ上で動作しているようだISIN-文字列で何か便利な操作を行うためのコードを、しようとします私の仕事では、私が問題を抱えていたものです。それがLOLのちょうど1秒だったとは信じられない。あなたの時間を大いに感謝します。 – deltahedge

関連する問題