teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2020/09/20 08:19

投稿

TanakaHiroaki
TanakaHiroaki

スコア1065

answer CHANGED
@@ -2,4 +2,34 @@
2
2
  ```VBA
3
3
  If win.LocationURL = "https://www.shopjapan.co.jp/shop/customer/entry" Then
4
4
  'If win.document.Url = "https://www.shopjapan.co.jp/shop/customer/entry" Then
5
+ ```
6
+
7
+ **追記**
8
+ Exit For の位置を変更してみました。
9
+ ```VBA
10
+ '開いているすべてのウインドウに対して処理する
11
+ For Each win In colSh.Windows
12
+
13
+ On Error Resume Next 'Window取得エラー対策
14
+ '開いているファイルの種類がHTMLなら処理を実行する
15
+ If TypeName(win.document) <> "HTMLDocument" Then
16
+ Else
17
+ '開いているサイトのURLが下記だったら
18
+ If win.LocationURL = "https://www.shopjapan.co.jp/shop/customer/entry" Then
19
+ 'If win.document.Url = "https://www.shopjapan.co.jp/shop/customer/entry" Then
20
+
21
+ 'このウインドウをobjIEとして指定する
22
+ Set objIE = win
23
+
24
+ objIE.document.getElementsByName("postCd")(0).Value = Range("D2").Value
25
+ objIE.document.getElementsByName("address1")(0).Value = Range("E2").Value
26
+ objIE.document.getElementsByName("address2")(0).Value = Range("F2").Value
27
+ objIE.document.getElementsByName("address3")(0).Value = Range("G2").Value
28
+
29
+ '処理を中断してFor~Nextを終了する
30
+ Exit For
31
+ End If
32
+ End If
33
+ On Error GoTo 0
34
+ Next
5
35
  ```

1

誤記修正

2020/09/20 08:18

投稿

TanakaHiroaki
TanakaHiroaki

スコア1065

answer CHANGED
@@ -2,5 +2,4 @@
2
2
  ```VBA
3
3
  If win.LocationURL = "https://www.shopjapan.co.jp/shop/customer/entry" Then
4
4
  'If win.document.Url = "https://www.shopjapan.co.jp/shop/customer/entry" Then
5
- ```
5
+ ```
6
- .LocationURL