質問編集履歴
2
追記\(ソース\)
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,156 @@
|
|
1
1
|
Windows10、Excel2016のVBAにてInternet Explorerからのデータ取得を行っております。処理中に「オートメーションエラーです。ライブラリの形式が古いか、または種類が無効です。」とのエラーメッセージが表示されます。良い解決方法があったら教えてください。よろしくお願いします。
|
2
2
|
|
3
|
-
追記:参照設定は、Visual Basic For Applications、Microsoft Excel 16.0 Object Library、OLE Automation、Microsoft Office 16.0 Object Library、Microsoft Forms 2.0 Object Library、Microsoft HTML Object Library、Microsoft Internet Controlsです。
|
3
|
+
追記:参照設定は、Visual Basic For Applications、Microsoft Excel 16.0 Object Library、OLE Automation、Microsoft Office 16.0 Object Library、Microsoft Forms 2.0 Object Library、Microsoft HTML Object Library、Microsoft Internet Controlsです。
|
4
|
+
|
5
|
+
ソース(一部)は以下のとおりです。
|
6
|
+
|
7
|
+
Sub GetTable1()
|
8
|
+
Dim ie As InternetExplorer
|
9
|
+
Dim Doc As HTMLDocument
|
10
|
+
Dim ObjTag As Object
|
11
|
+
Dim ObjElements As Object
|
12
|
+
Dim WorkbookBackNumber As Workbook
|
13
|
+
Dim WorkbookBatting As Workbook
|
14
|
+
Dim WorkbookFielding As Workbook
|
15
|
+
Dim WorkbookStandardPitching As Workbook
|
16
|
+
Dim WorkbookBattingAgainst As Workbook
|
17
|
+
Dim WorkbookRelieverPitching As Workbook
|
18
|
+
(宣言を一部省略)
|
19
|
+
'年度を指定
|
20
|
+
iYear = 1888
|
21
|
+
|
22
|
+
'選手IDを指定
|
23
|
+
playerNo = 3
|
24
|
+
|
25
|
+
'MLBのURLを指定
|
26
|
+
strURLMLB = "http://www.baseball-reference.com/leagues/NL/1888.shtml"
|
27
|
+
|
28
|
+
'球団名を指定
|
29
|
+
strTeamNm(1) = "NYG"
|
30
|
+
strTeamNm(2) = "CHC"
|
31
|
+
strTeamNm(3) = "PHI"
|
32
|
+
strTeamNm(4) = "BSN"
|
33
|
+
strTeamNm(5) = "DTN"
|
34
|
+
strTeamNm(6) = "PIT"
|
35
|
+
strTeamNm(7) = "IND"
|
36
|
+
strTeamNm(8) = "WHS"
|
37
|
+
|
38
|
+
'IEを開いて操作対象画面へ遷移
|
39
|
+
Set ie = CreateObject("InternetExplorer.Application")
|
40
|
+
|
41
|
+
ie.Visible = True
|
42
|
+
ie.Navigate strURLMLB '"http://kakaku.com/pc/note-pc/se_15/"
|
43
|
+
Call waitNavigation(ie)
|
44
|
+
Set Doc = ie.document
|
45
|
+
|
46
|
+
(一部省略)
|
47
|
+
|
48
|
+
Workbooks.Open "C:\Users\yoima\Documents\プロ野球\データベース\ExcelDat\" & iYear & "\選手名鑑(メジャー).xls"
|
49
|
+
Set WorkbookPlayerList = Workbooks("選手名鑑(メジャー).xls")
|
50
|
+
|
51
|
+
iTeamLast = 1
|
52
|
+
|
53
|
+
(一部省略)
|
54
|
+
For iCnt = iTeamLast To 30
|
55
|
+
|
56
|
+
If strTeamNm(iCnt) = "" Then Exit For
|
57
|
+
|
58
|
+
'チームのURLを指定
|
59
|
+
ie.Navigate strURLTeam(iCnt) '"http://kakaku.com/pc/note-pc/se_15/"
|
60
|
+
Call waitNavigation(ie)
|
61
|
+
|
62
|
+
ReDim strURLPlayer(0)
|
63
|
+
ReDim strPlayerName(0)
|
64
|
+
ReDim strPosition(0)
|
65
|
+
URLSize = -1
|
66
|
+
|
67
|
+
'Debug.Print Doc.all.Length
|
68
|
+
|
69
|
+
(一部省略)
|
70
|
+
For i = playerFirst To UBound(strURLPlayer)
|
71
|
+
|
72
|
+
(一部省略)
|
73
|
+
|
74
|
+
GetBackNumberFlg = False
|
75
|
+
GetBattingFlg = False
|
76
|
+
GetFieldingFlg = False
|
77
|
+
GetPitchingInfoFlg = False
|
78
|
+
|
79
|
+
(一部省略)
|
80
|
+
|
81
|
+
If Doc.all(j).tagName = "DIV" Then
|
82
|
+
|
83
|
+
'ヘッダ
|
84
|
+
If Doc.all(j).ID = "div_batting_standard" Then
|
85
|
+
|
86
|
+
'打撃成績ファイルの作成
|
87
|
+
If Dir("C:\Users\yoima\Documents\プロ野球\データベース\ExcelDat\" & iYear & "\打撃成績(メジャー)\Batting_" & playerNo & ".xls") <> "" Then
|
88
|
+
|
89
|
+
Workbooks.Open "C:\Users\yoima\Documents\プロ野球\データベース\ExcelDat\" & iYear & "\打撃成績(メジャー)\Batting_" & playerNo & ".xls"
|
90
|
+
Else
|
91
|
+
Workbooks.Add
|
92
|
+
strBookName = ActiveWorkbook.Name
|
93
|
+
Workbooks(strBookName).SaveAs "C:\Users\yoima\Documents\プロ野球\データベース\ExcelDat\" & iYear & "\打撃成績(メジャー)\Batting_" & playerNo & ".xls"
|
94
|
+
End If
|
95
|
+
|
96
|
+
'Set WorkbookBatting = Workbooks("Batting_" & playerNo & ".xls")
|
97
|
+
Set WorkbookBatting = ActiveWorkbook
|
98
|
+
|
99
|
+
WorkbookBatting.Sheets("Sheet1").Cells(1, 1) = Doc.all(j + 35).innerText 'Year
|
100
|
+
(一部省略)
|
101
|
+
|
102
|
+
End If
|
103
|
+
|
104
|
+
End If
|
105
|
+
|
106
|
+
If Doc.all(j).tagName = "TR" Then
|
107
|
+
|
108
|
+
If InStr(Doc.all(j).ID, "batting_standard") > 0 Then
|
109
|
+
|
110
|
+
k = 2
|
111
|
+
|
112
|
+
Do
|
113
|
+
|
114
|
+
If Doc.all(j).tagName = "TR" And (InStr(Doc.all(j + 1).innerText, "Yrs") > 0 Or InStr(Doc.all(j + 1).innerText, "Yr") > 0) Then Exit Do '末尾になったら終了
|
115
|
+
|
116
|
+
If Doc.all(j).tagName = "TR" Then
|
117
|
+
|
118
|
+
If ((InStr(Doc.all(j).ID, "batting_standard.") > 0) Or (Doc.all(j).className = "partial_table")) And (Doc.all(j + 1).innerText = iYear) Then
|
119
|
+
|
120
|
+
StrongEmCnt = 0
|
121
|
+
|
122
|
+
'データ
|
123
|
+
WorkbookBatting.Sheets("Sheet1").Cells(k, 1) = Doc.all(j + 1).innerText 'Year
|
124
|
+
|
125
|
+
(一部省略)
|
126
|
+
j = j + 31 + StrongEmCnt
|
127
|
+
|
128
|
+
Do Until Doc.all(j).tagName = "TR" '次年度の先頭行へ移動
|
129
|
+
|
130
|
+
j = j + 1
|
131
|
+
Loop
|
132
|
+
|
133
|
+
k = k + 1
|
134
|
+
Else
|
135
|
+
j = j + 1
|
136
|
+
|
137
|
+
Do Until Doc.all(j).tagName = "TR" '次年度の先頭行へ移動
|
138
|
+
|
139
|
+
j = j + 1
|
140
|
+
Loop
|
141
|
+
|
142
|
+
End If
|
143
|
+
End If
|
144
|
+
Loop
|
145
|
+
|
146
|
+
WorkbookPlayerList.Save
|
147
|
+
|
148
|
+
WorkbookBatting.Save
|
149
|
+
WorkbookBatting.Close
|
150
|
+
|
151
|
+
GetBattingFlg = True
|
152
|
+
End If
|
153
|
+
|
154
|
+
End If
|
155
|
+
|
156
|
+
(以下略)
|
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,1 +1,3 @@
|
|
1
|
-
Windows10、Excel2016のVBAにてInternet Explorerからのデータ取得を行っております。処理中に「オートメーションエラーです。ライブラリの形式が古いか、または種類が無効です。」とのエラーメッセージが表示されます。良い解決方法があったら教えてください。よろしくお願いします。
|
1
|
+
Windows10、Excel2016のVBAにてInternet Explorerからのデータ取得を行っております。処理中に「オートメーションエラーです。ライブラリの形式が古いか、または種類が無効です。」とのエラーメッセージが表示されます。良い解決方法があったら教えてください。よろしくお願いします。
|
2
|
+
|
3
|
+
追記:参照設定は、Visual Basic For Applications、Microsoft Excel 16.0 Object Library、OLE Automation、Microsoft Office 16.0 Object Library、Microsoft Forms 2.0 Object Library、Microsoft HTML Object Library、Microsoft Internet Controlsです。
|