下記のjavascriptのfileをエクセルVBAから立ち上げていますが、EXCEL VBAの中から実行したいと思ってるのですが、わかりません。やることは、VBAからホームページ内のパスワードを入力して、ページを進んでいくだけなのです。その最後の行きたいページをexcelVBAのコードの中で実行したいと思ってます。

出来ればEXCEL VBAのサンプルコードを教えてほしいです。
var IE = WScript.CreateObject("InternetExplorer.Application");
IE.Visible = true;
IE.Navigate("http://dms.aaanet/aaa/GetPubliLogin.do");
while(IE.busy) ;
while(IE.Document.readyState != "complete") ;
IE.Document.all('loginForm').username.value = "15555893";
IE.Document.all('loginForm').password.value = "02222";
IE.Document.all('loginForm').submit();
while(IE.busy) ;
while(IE.Document.readyState != "complete") ;
var modelName ="C777";
var modelTitle="777";
var nodeId="2";
function switchPublication(modelName,modelTitle, nodeId){
IE.Document.publicationForm.modelName.value = modelName;
IE.Document.publicationForm.modelTitle.value = modelTitle;
IE.Document.publicationForm.tocId.value = modelName;
IE.Document.publicationForm.nodeId.value = nodeId;
IE.Document.publicationForm.submit();
}
switchPublication('C777','777', '2');
while(IE.busy) ;
while(IE.Document.readyState != "complete") ;
IE.Navigate("http://dms.aaaa/AAL/ViewAsPDF.do?WSb=C877");

回答の条件
  • 1人2回まで
  • 登録:
  • 終了:2009/10/12 19:57:40
※ 有料アンケート・ポイント付き質問機能は2023年2月28日に終了しました。

ベストアンサー

id:HALSPECIAL No.1

回答回数407ベストアンサー獲得回数86

ポイント100pt

未確認ですが、こちらでいかがでしょう。

ExcelVBAで利用できるようにコンバートしました。

Main 関数をコールしてください。


Option Explicit

Dim IE

Public Sub Main()
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    IE.Navigate "http://dms.aaanet/aaa/GetPubliLogin.do"
    Do While IE.Busy
        DoEvents
    Loop
    Do While IE.Document.ReadyState <> "complete"
        DoEvents
    Loop
    IE.Document.loginForm.username.Value = "15555893"
    IE.Document.loginForm.password.Value = "02222"
    IE.Document.loginForm.Submit
    Do While IE.Busy
        DoEvents
    Loop
    Do While IE.Document.ReadyState <> "complete"
        DoEvents
    Loop
    Dim modelName, modelTitle, nodeId
    modelName ="C777"
    modelTitle="777"
    nodeId="2"

    Call switchPublication("C777","777", "2")
    Do While IE.Busy
        DoEvents
    Loop
    Do While IE.Document.ReadyState <> "complete"
        DoEvents
    Loop
    IE.Navigate "http://dms.aaaa/AAL/ViewAsPDF.do?WSb=C877"
End Sub

Private Function switchPublication(modelName,modelTitle, nodeId)
    IE.Document.publicationForm.modelName.Value = modelName
    IE.Document.publicationForm.modelTitle.Value = modelTitle
    IE.Document.publicationForm.tocId.Value = modelName
    IE.Document.publicationForm.nodeId.Value = nodeId
    IE.Document.publicationForm.Submit
End Function

id:shotomo

完璧に思うとおりに動きました。ありがとうございます

2009/10/12 19:57:11

コメントはまだありません

この質問への反応(ブックマークコメント)

「あの人に答えてほしい」「この質問はあの人が答えられそう」というときに、回答リクエストを送ってみてましょう。

これ以上回答リクエストを送信することはできません。制限について

回答リクエストを送信したユーザーはいません