MACRO/EXCEL-MACRO

filedialogObject 사용시 초기 폴더위치 지정하기

kyoohyo 2016. 10. 13. 14:56

엑셀 매크로에서 폴더 창을 띄울 때 원하는 창으로 들어가는 방법

폴더의 initialFileName을 정해주면 된다.

아래와 같음

 

Dim fd As FileDialog

Set fd = application.filedialog(msofiledialogfilepicker)

set fs = createobject("scripting.FileSystemObject")

 

Cells(3,1) = ""

with fd

.InitialFileName = "D:\temp\"

.AllowMultiSselect = true

If .show = 0 then

cells(3,1) = "작업을 취소하셨습니다."

cells(3,1).font.color = RGB(240,0,0)

cells(3,1).font.bold = true

else

.....

end if

end with

set fd = nothing