回答編集履歴
1
<code>を使った方法へ記述を入れ替え
test
CHANGED
@@ -8,19 +8,15 @@
|
|
8
8
|
|
9
9
|
私にはこれしかやり方が分かりません。
|
10
10
|
|
11
|
-
'-----------------------------------------------
|
12
|
-
|
13
|
-
|
11
|
+
```ここに言語を入力
|
14
|
-
|
15
|
-
|
16
12
|
|
17
13
|
Option Explicit
|
18
14
|
|
19
|
-
'*******************************************
|
15
|
+
'*******************************************
|
20
16
|
|
21
17
|
' Private Work Area
|
22
18
|
|
23
|
-
'*******************************************
|
19
|
+
'*******************************************
|
24
20
|
|
25
21
|
Private strFilter As String
|
26
22
|
|
@@ -28,63 +24,57 @@
|
|
28
24
|
|
29
25
|
Private strDefFolderName As String
|
30
26
|
|
31
|
-
'*******************************************
|
27
|
+
'*******************************************
|
32
28
|
|
33
29
|
' API Area
|
34
30
|
|
35
|
-
'*******************************************
|
31
|
+
'*******************************************
|
36
|
-
|
37
|
-
|
32
|
+
|
38
|
-
|
39
|
-
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA"
|
33
|
+
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (lpofn As OPENFILENAME) As Long
|
40
|
-
|
41
|
-
(lpofn As OPENFILENAME) As Long
|
42
34
|
|
43
35
|
Private Type OPENFILENAME
|
44
36
|
|
45
|
-
|
37
|
+
lStructSize As Long '構造体のサイズ
|
46
|
-
|
38
|
+
|
47
|
-
|
39
|
+
hwndOwner As Long 'ダイアログボックスの親ウィンドウハンドル
|
48
|
-
|
40
|
+
|
49
|
-
|
41
|
+
hInstance As Long 'テンプレートリソースを持つモジュールのインスタンスハンドル(不用のとき0)
|
50
|
-
|
42
|
+
|
51
|
-
|
43
|
+
lpstrFilter As String 'フィルタ(Visual Basicのファイルパターンのこと)
|
52
|
-
|
44
|
+
|
53
|
-
|
45
|
+
lpstrCustomFilter As String 'カスタムフィルタ
|
54
|
-
|
46
|
+
|
55
|
-
|
47
|
+
nMaxCustomFilter As Long '同、バイト数
|
56
|
-
|
48
|
+
|
57
|
-
|
49
|
+
nFilterIndex As Long 'ダイアログに優先的に表示するフィルタのインデックス
|
58
|
-
|
50
|
+
|
59
|
-
|
51
|
+
lpstrFile As String '(戻り値)フルパス名を受け取るバッファ
|
60
|
-
|
52
|
+
|
61
|
-
|
53
|
+
nMaxFile As Long '同、バイト数
|
62
|
-
|
54
|
+
|
63
|
-
|
55
|
+
lpstrFileTitle As String '(戻り値)ファイル名を受け取るバッファ
|
64
|
-
|
56
|
+
|
65
|
-
|
57
|
+
nMaxFileTitle As Long '同、バイト数
|
66
|
-
|
58
|
+
|
67
|
-
|
59
|
+
lpstrInitialDir As String '初期のディレクトリ名
|
68
|
-
|
60
|
+
|
69
|
-
|
61
|
+
lpstrTitle As String 'ダイアログのキャプション
|
70
|
-
|
62
|
+
|
71
|
-
|
63
|
+
flags As Long '動作を指定
|
72
|
-
|
64
|
+
|
73
|
-
|
65
|
+
nFileOffset As Integer 'フルパス中のファイル名までのオフセット
|
74
|
-
|
66
|
+
|
75
|
-
|
67
|
+
nFileExtension As Integer '同、拡張子までのオフセット
|
76
|
-
|
68
|
+
|
77
|
-
|
69
|
+
lpstrdefext As String 'デフォルトの拡張子
|
78
|
-
|
70
|
+
|
79
|
-
|
71
|
+
lCustData As Long 'フックプロシージャに渡すデータ
|
80
|
-
|
72
|
+
|
81
|
-
|
73
|
+
lpfnHook As Long 'フックプロシージャへのポインタ
|
82
|
-
|
74
|
+
|
83
|
-
|
75
|
+
lpTemplateName As String 'テンプレートリソース名
|
84
|
-
|
76
|
+
|
85
|
-
End Type
|
77
|
+
End Type
|
86
|
-
|
87
|
-
|
88
78
|
|
89
79
|
'uFlagsの定数
|
90
80
|
|
@@ -132,176 +122,150 @@
|
|
132
122
|
|
133
123
|
Private Const OFN_NONETWORKBUTTON = &H20000 'ネットワークボタンを非表示・無効にする
|
134
124
|
|
135
|
-
Private Const OFN_SHAREAWARE = &H4000 'ファイルを開いたときにネットワーク共有違反のためエラーが発生してもエラーを無視する
|
125
|
+
Private Const OFN_SHAREAWARE = &H4000 'ファイルを開いたときにネットワーク共有違反のためエラーが発生してもエラーを無視する
|
136
|
-
|
137
|
-
|
138
126
|
|
139
127
|
Private lpofn As OPENFILENAME
|
140
128
|
|
141
|
-
'
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
'
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
'
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
'
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
'
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
D
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
D
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
E
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
129
|
+
'
|
130
|
+
|
131
|
+
'**************************************************************
|
132
|
+
|
133
|
+
' @(f)
|
134
|
+
|
135
|
+
' Function : OpenFileDialog
|
136
|
+
|
137
|
+
' Return : True:Nomal False:Abnomal
|
138
|
+
|
139
|
+
' Argument :
|
140
|
+
|
141
|
+
' Description :
|
142
|
+
|
143
|
+
' Note :
|
144
|
+
|
145
|
+
'**************************************************************
|
146
|
+
|
147
|
+
Private Function OpenFileDialog() As Boolean
|
148
|
+
|
149
|
+
Dim fs As Object
|
150
|
+
|
151
|
+
Dim MyFolder As Object
|
152
|
+
|
153
|
+
Dim MyPath As String
|
154
|
+
|
155
|
+
Dim strFileName As String
|
156
|
+
|
157
|
+
Dim blnErr As Boolean
|
158
|
+
|
159
|
+
Dim lpofn As OPENFILENAME
|
160
|
+
|
161
|
+
Dim rc As Variant
|
162
|
+
|
163
|
+
Dim a As Long
|
164
|
+
|
165
|
+
Set fs = CreateObject("Scripting.FileSystemObject")
|
166
|
+
|
167
|
+
If fs.FolderExists(strDefFolderName) = False Then
|
168
|
+
|
169
|
+
MsgBox "Error Exist:" & strDefFolderName
|
170
|
+
|
171
|
+
Exit Function
|
172
|
+
|
173
|
+
Else
|
174
|
+
|
175
|
+
MyPath = strDefFolderName
|
176
|
+
|
177
|
+
End If
|
178
|
+
|
179
|
+
With lpofn
|
180
|
+
|
181
|
+
'
|
182
|
+
|
183
|
+
.flags = OFN_PATHMUSTEXIST Or OFN_HIDEREADONLY
|
184
|
+
|
185
|
+
.lStructSize = Len(lpofn)
|
186
|
+
|
187
|
+
'.hwndOwner = Application.hWndAccessApp
|
188
|
+
|
189
|
+
.lpstrFileTitle = String(512, Chr(0))
|
190
|
+
|
191
|
+
.nMaxFileTitle = 512
|
192
|
+
|
193
|
+
.lpstrFile = String(512, Chr(0))
|
194
|
+
|
195
|
+
.nMaxFile = 512
|
196
|
+
|
197
|
+
.lpstrTitle = "Select Variable Definition File"
|
198
|
+
|
199
|
+
.lpstrFilter = strFilter
|
200
|
+
|
201
|
+
.lpstrInitialDir = MyPath
|
202
|
+
|
203
|
+
.nFilterIndex = 1
|
204
|
+
|
205
|
+
.lpstrFile = String(512, Chr(0))
|
206
|
+
|
207
|
+
'
|
208
|
+
|
209
|
+
rc = GetOpenFileName(lpofn)
|
210
|
+
|
211
|
+
If rc > 0 Then
|
212
|
+
|
213
|
+
a = InStr(.lpstrFile, Chr(0))
|
214
|
+
|
215
|
+
strFileName = Mid(.lpstrFile, 1, a - 1)
|
216
|
+
|
217
|
+
blnErr = False
|
218
|
+
|
219
|
+
Else
|
220
|
+
|
221
|
+
'No Select
|
222
|
+
|
223
|
+
Set fs = Nothing
|
224
|
+
|
225
|
+
Exit Function
|
226
|
+
|
227
|
+
End If
|
228
|
+
|
229
|
+
'
|
230
|
+
|
231
|
+
End With
|
232
|
+
|
233
|
+
Set fs = Nothing
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
End Function
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
Public Function runOpenFileDialog_Excel() As Boolean
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
'-------------------------------------------
|
246
|
+
|
247
|
+
'ネットワークフォルダ名を指定
|
248
|
+
|
249
|
+
strDefFolderName = "\192.168.3.4\test"
|
250
|
+
|
251
|
+
'-------------------------------------------
|
252
|
+
|
253
|
+
strFilter = ""
|
254
|
+
|
255
|
+
strFilter = strFilter & "Excel File(*.xls)" + Chr(0) + "*.xls" + Chr(0) + ""
|
256
|
+
|
257
|
+
strFilter = strFilter & "Excel File(*.xlsx)" + Chr(0) + "*.xlsx" + Chr(0) + ""
|
258
|
+
|
259
|
+
strFilter = strFilter & "All File(*.*)" + Chr(0) + "*.*"
|
260
|
+
|
261
|
+
If OpenFileDialog() = False Then
|
262
|
+
|
263
|
+
Exit Function
|
264
|
+
|
265
|
+
End If
|
274
266
|
|
275
267
|
|
276
268
|
|
277
269
|
End Function
|
278
270
|
|
279
|
-
|
280
|
-
|
281
|
-
Public Function runOpenFileDialog_Excel() As Boolean
|
282
|
-
|
283
|
-
'-------------------------------------------
|
284
|
-
|
285
|
-
'ネットワークフォルダ名を指定
|
286
|
-
|
287
|
-
strDefFolderName = "\172.16.5.100\test\test"
|
288
|
-
|
289
|
-
'-------------------------------------------
|
290
|
-
|
291
|
-
strFilter = ""
|
292
|
-
|
293
|
-
strFilter = strFilter & "Excel File(*.xls)" + Chr(0) + "*.xls" + Chr(0) + ""
|
294
|
-
|
295
|
-
strFilter = strFilter & "Excel File(*.xlsx)" + Chr(0) + "*.xlsx" + Chr(0) + ""
|
296
|
-
|
297
|
-
strFilter = strFilter & "All File(*.*)" + Chr(0) + "*.*"
|
298
|
-
|
299
|
-
If OpenFileDialog() = False Then
|
300
|
-
|
301
|
-
Exit Function
|
302
|
-
|
303
|
-
|
271
|
+
```
|
304
|
-
|
305
|
-
End Function
|
306
|
-
|
307
|
-
'-----------------------------------------------
|