ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] 2003»P2007±o¨ìªº¸ô®|®t²§

¦^´_ 9# maiko

InitialFileName¬O¥i¥H¥Î¨Ó«ü©w¹ï¸Üµøµ¡¤¤ªº¹w³Æ¥Ø¿ý
­Y¥¼«ü©wInitialFileName«h·|¥H¿ï¶µ¤¤ªº¹w³]¦sÀɥؿý§@¬°¹ï¸Üµøµ¡¹w³]¥Ø¿ý
¦ÓSelectedItems¤~¬O©Ò¿ï¾Üªº¸ê®Æ§¨
©Ò¥H¡A©p­n¼g¤JªºÀ³¸Ó¬O   SelectedItems¦Ó¤£¬OInitialFileName
³o¼ËSelectedItems¤£ºÞ¬O2003©Î2007³£¬O¤£§t³Ì«áªº±×½u
  1. Sub OpenPath()
  2. Dim fd As FileDialog, FileName As String, FileFolder As String
  3. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  4. With fd
  5.      .InitialFileName = "E:\"  '«ü©w¹ï¸Üµøµ¡ªº¥Ø¿ý
  6.      .AllowMultiSelect = False
  7.     If .Show = -1 Then
  8.         FileFolder = .SelectedItems(1)   '¿ï¾Üªº¸ê®Æ§¨
  9.     Else
  10.         End
  11.     End If
  12. End With
  13. [F2] = FileFolder
  14. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¶i¤J³o¥DÃD¾Ç¨ì¤£¤Ö
·j´M¾Ç¨ì¡A¶¶«K¤À¨É¤@¤U¡A¸û±`¥ÎDefaultFilePathÁקK¤W­zÅܤÆ
¦³ªÅ¸Õ¸Õ¡A¾Ç²ß¤@¤UFileDialog·f°t¹B¥Î


¦ÛExcel XP(2002)°_¡AApplication¦h¤F¤@­ÓFileDialogÄÝ©Ê¡CFileDialog ÄݩʶǦ^ FileDialog ª«¥ó¡A¦¹ª«¥ó¥NªíÀÉ®×¹ï¸Ü¤è¶ôªº°õ¦æ­ÓÅé¡C

¥Îªk¡G
Application.FileDialog(fileDialogType)
fileDialogType ¥²¿ïªº MsoFileDialogType¡CÀÉ®×¹ï¸Ü¤è¶ôªºÃþ«¬¡C
MsoFileDialogType ¥i¥H¬O³o¨Ç MsoFileDialogType ±`¼Æ¤§¤@¡C

    msoFileDialogFilePicker ¤¹³\¨Ï¥ÎªÌ¿ï¨úÀɮסC
    msoFileDialogFolderPicker ¤¹³\¨Ï¥ÎªÌ¿ï¨ú¸ê®Æ§¨¡C
    msoFileDialogOpen ¤¹³\¨Ï¥ÎªÌ¶}±ÒÀɮסC
    msoFileDialogSaveAs ¤¹³\¨Ï¥ÎªÌÀx¦sÀɮסC

FileDialog ª«¥ó´£¨ÑÀÉ®×¹ï¸Ü¤è¶ô¥\¯à¡AÃþ¦ü Microsoft Office À³¥Îµ{¦¡¤¤ªº¼Ð·Ç [¶}±ÒÂÂÀÉ] ¤Î [Àx¦sÀÉ®×] ¹ï¸Ü¤è¶ô¥\¯à¡C¹B¥Î³o¨Ç¹ï¸Ü¤è¶ô¡A¾ã¦X¤è®×ªº¨Ï¥ÎªÌ¥i¥H«Ü®e©ö¦a«ü©w¸Ó¤è®×À³¨Ï¥ÎªºÀɮפθê®Æ§¨¡C

¨Ï¥Î FileDialog ª«¥ó
¥H FileDialog ÄݩʶǦ^ FileDialog ª«¥ó¡CFileDialog Äݩʦì¦b¨C­Ó³æ¿Wªº Office À³¥Îµ{¦¡ Application ª«¥ó¤¤¡CÄݩʨϥΤ@­Ó¤Þ¼Æ DialogType¡A¥H½T©wÄݩʩҶǦ^ªº FileDialog ª«¥óÃþ«¬¡C¤U¦C¬O FileDialog ª«¥óªº 4 ºØÃþ«¬¡G

    [¶}±ÒÂÂÀÉ] ¹ï¸Ü¤è¶ô¡GÅý¨Ï¥ÎªÌ¿ï¨ú¤@©Î¦h­ÓÀɮסA¥i¨Ï¥Î Execute ¤èªk¦b¥DÀ³¥Îµ{¦¡¤¤¶}±Ò¡C
    [¥t¦s·sÀÉ] ¹ï¸Ü¤è¶ô¡GÅý¨Ï¥ÎªÌ¿ï¨ú¤@­ÓÀɮסA¥i¨Ï¥Î Execute ¤èªkÀx¦s¥Ø«eªºÀɮסC
    [Àɮ׿ï¾Ü¾¹] ¹ï¸Ü¤è¶ô¡GÅý¨Ï¥ÎªÌ¿ï¨ú¤@©Î¦h­ÓÀɮסC¦b FileDialogSelectedItems ¶°¦X¤¤Â^¨ú¨Ï¥ÎªÌ©Ò¿ï¨úªºÀɮ׸ô®|¡C
    [¸ê®Æ§¨¿ï¾Ü¾¹] ¹ï¸Ü¤è¶ô¡GÅý¨Ï¥ÎªÌ¿ï¨ú¸ô®|¡C¦b FileDialogSelectedItems ¶°¦X¤¤Â^¨ú¨Ï¥ÎªÌ©Ò¿ï¨úªº¸ô®|¡C

¨C­Ó¥DÀ³¥Îµ{¦¡¥u¯à¨Ò¥Ü FileDialog ª«¥óªº³æ­Ó¹ê¨Ò¡C¦]¦¹¡A§Y¨Ï·í«Ø¥ß¦h­Ó FileDialog ª«¥ó®É¡A¥ç«O¯d FileDialog ª«¥óªº³\¦hÄÝ©Ê¡C¦]¦¹¡A½Ð½T»{¦bÅã¥Ü¸Ó¹ï¸Ü¤è¶ô«e¡A¤w³]©w¾A¦X±z¥Øªº¤§©Ò¦³ÄÝ©Ê¡C

¬°¤F¨Ï¥Î FileDialog ª«¥óÅã¥Ü¹ï¸Ü¤è¶ô¡A±z¥²¶·¨Ï¥Î Show ¤èªk¡C¤@¥¹Åã¥Ü¹ï¸Ü¤è¶ô¡A´N·|¦b¨Ï¥ÎªÌµ²§ô¸Ó¹ï¸Ü¤è¶ô¤§«á¤~°õ¦æµ{¦¡½X¡C
100 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^³ø¤@¤U´ú¸Õµ²ªG¡A¨Ñ°Ñ¦Ò
Win7+OFFICE 2010
OpenPath4
¨Ï¥Î«á´ú¸Õµ²ªG d:\SaveExcel\20121009
¦ý¤U¦¸¿ï¨ú®É¬°¸õ¨ì¥Ø¿ý¬° d:\SaveExcel

OpenPath5
¨Ï¥Î«á´ú¸Õµ²ªGd:\SaveExcel\
¤@¼Ë¤U¦¸¿ï¨ú®É¬°¸õ¨ì¥Ø¿ý¬° d:\SaveExcel
  1.     Sub OpenPath4()
  2.     Dim fd As FileDialog, FileName As String, FileFolder As String
  3.     Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  4.     With fd
  5.         .AllowMultiSelect = False
  6.         If .Show = -1 Then
  7.             FileFolder = .SelectedItems(1)  '#1
  8.         Else
  9.             End
  10.         End If
  11.     End With
  12.     [F2] = FileFolder  '#2
  13.     End Sub
½Æ»s¥N½X
  1. Sub OpenPath5()
  2. Dim fd As FileDialog, FileName As String, FileFolder As String
  3. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  4. With fd
  5.     .AllowMultiSelect = False
  6.     If .Show = -1 Then
  7.         FileFolder = .InitialFileName
  8.     Else
  9.         End
  10.     End If
  11. End With
  12. [F2] = fd.InitialFileName
  13. End Sub
½Æ»s¥N½X
100 ¦r¸`¥H¤º
¤£¤ä«ù¦Û©w¸q Discuz! ¥N½X

TOP

¦^´_ 8# maiko
¦Ó§Ú¥Îstillfish00¤j´£¨Ñªº¨ú±oªºÀɮ׸ô®|«o¬O¡Gd:\SaveExcel\20101009¡A«á­±¤Ö¤F¡u\¡v           
¤£¤@¼Ëªº  1# ¬O Sheet1.Range("F2") = fd.InitialFileName
stillfish00 2# ¬O Sheet1.Range("F2") = FileFolder

TOP

¦^´_  maiko
¦Ó§Ú¥Îstillfish00¤j´£¨Ñªº¨ú±oªºÀɮ׸ô®|«o¬O¡Gd:\SaveExcel\20101009¡A«á­±¤Ö¤F¡u\¡v      ...
GBKEE µoªí©ó 2012-10-10 07:37



   

FileFolder = .InitialFileName
¤]´N¬O¡G
FileFolder = fd.InitialFileName
¹ïµ¥¤½¦¡¡C
¸Õ¹L¤F¡Aµ²ªG¤@¼Ë¡A°ß¦³¹³ stillfish00 ¤j»¡ªº¤@¼Ë¡A¦b«á­±¥[¤W & "\" ¡A¨º»òµL½×¬Æ»òª©¥»ªºExcel³£¥i¥H¥Î¨ì¡A²Î¤@¼Ë¦¡¡A¤£·|Åý¥H«á§ï¤Fª©¥»´N¥Î¤£¨ì¡C

ÁÂÁ³o»ò¦h¦ì°ª¤âªºÀ°§U¡AÅý§Ú§ó¤F¸Ñ¤FFileDialogªºÄÝ©Ê¡AÁÂÁ¡I

TOP

¦^´_ 15# maiko
«Ü©êºp¨S»¡²M·¡ ½Ð¦A¬Ý  2# ªºµ{¦¡½X ¦³ FileFolder = .SelectedItems(1)   
stillfish00 2# ¬O Sheet1.Range("F2") = FileFolder ¬O³Ì«á¨S¦³ "\"

TOP

¦^´_  maiko
«Ü©êºp¨S»¡²M·¡ ½Ð¦A¬Ý  2# ªºµ{¦¡½X ¦³ FileFolder = .SelectedItems(1)   
stillfish00 2 ...
GBKEE µoªí©ó 2012-10-10 08:28



   

¨º»ò¨Ì§A©Ò¨£¡A¬O¤£¬OSheet1.Range("F2") = FileFolder ³Ì«á¬O¨S¦³¡u\¡v¡A¨º»òÀ³¸Ó¥Î¤°»ò¤~·|¦³¡u\¡v¡H¤£¥Î«á­±¦Û¤v¥[& "\"¡H

TOP

¦^´_ 17# maiko
  1. Option Explicit
  2. Sub OpenPath()
  3. Dim fd As FileDialog, FileName As String, FileFolder As String
  4. Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  5. With fd
  6.      .InitialFileName = "E:\"  '«ü©w¹ï¸Üµøµ¡ªº¥Ø¿ý
  7.      .AllowMultiSelect = False
  8.     If .Show = -1 Then
  9.         FileFolder = .SelectedItems(1)   '¿ï¾Üªº¸ê®Æ§¨
  10.         [F2] = .SelectedItems(1)      '³Ì«á¨S"\"
  11.         [F3] = fd.InitialFileName    '¦³"\"
  12.     Else
  13.         End
  14.     End If
  15. End With
  16. End Sub
½Æ»s¥N½X

TOP

¦^´_  maiko
GBKEE µoªí©ó 2012-10-10 12:42



   
ÁÂÁ¤j¤jªº¼ö¤ßÀ°¦£¡A¤£¹L¤j¤j¦n¹³¤£©ú¥Õ§Ú«e­±©ÒÁ¿ªº­n¨D¡G

InitialFileName¦pªG¥Î¦b2003¤W¬O§¹¥þ¥i¥H¨ú±o§¹¾ãªº¸ô®|¡A¦p¡Gd:\SaveExcel\20121009\
¥i¬OInitialFileName¦pªG¥Î¦b2007¤W«o¬O±o¨ìªº¸ô®|·|¤Ö¤F¤@¼h¡A¦p¡Gd:\SaveExcel\¡A³o¤]´N¬O§A»¡ªº«á­±¦³"\"¡A¥i¬O¸ô®|¤£§¹¾ã¡C

¦pªG¥ÎSelectedItems(1)¡A¨º»ò¦b2003©Î2007¡]¦]¬°§Ú¨S¦³2010¡A¥i¬O¤§«e¦³¤j¤j¦b2010¤W¸Õ¹L¡^¬O¥i¥H¨ú±o¨ì¤ñ¸û§¹¾ãªº¸ô®|¡A¦p¡Gd:\SaveExcel\20121009¡A«á­±´N¨S¦³"\"¡A´N¦pstillfish00¤j»¡¹Lªº¨º¼Ë¡A°ß¦³¦Û¤v¥[¤W& "\"¡A¤£ª¾¹D³o¼Ë»¡©ú§A¯à²M·¡¶Ü¡H

½Ð¸Õ¦h´X¦¸¥N½Xªº°Ï§O¡AÁÂÁ¤j¤jªº¼ö¤ßÀ°¦£¡I

TOP

¦^´_ 19# maiko
¥i¬OInitialFileName¦pªG¥Î¦b2007¤W«o¬O±o¨ìªº¸ô®|·|¤Ö¤F¤@¼h
§Ú¥u¦³2003ª© ©Ò¥H³o®t²§§ÚµL±q°Ñ»Pªº.

TOP

        ÀR«ä¦Û¦b : ¦³Ä@©ñ¦b¤ß¸Ì¡A¨S¦³¨­Åé¤O¦æ¡A¥¿¦p¯Ñ¥Ð¤£¼½ºØ¡A¬Ò¬OªÅ¹L¦]½t¡C
ªð¦^¦Cªí ¤W¤@¥DÃD