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

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

¦^³ø¤@¤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

¶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

¦^´_ 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

¦^´_ 5# maiko
Hi , §Ú®a¬Owin7+Excel2010 ,

§Ú¤S¸Õ¤F¤@¹M , ½T¹ê .InitialFileName ¤]·|ÀH¨Ï¥ÎªÌ¾Þ§@«á§ïÅܸô®| , ¥u¬O·íªì¨S·Q¨ìÁÙ¯à³o¼Ë°µ¬°¦^¶Çµ²ªG , ¦ý¦pªG¨S¯S®í»Ý¨D§ÚÁÙ¬O·|¥Î .SelectedItems¨ú¦^µ²ªG°Õ , ¤Ö­Ó±×½u´N¥Î²Â¤èªk & "\" ¦Û¤v¥[¤W¥h:L

µM«áwin7+Excel2010¤U , ¨Ï¥Î .InitialFileName¤]¸ò§A¤@¼Ë¤Ö¤@¼h , ¦ý¸òApplication.DefaultFilePath¤£¤@­P , ¤Ï¦Ó¬O¸òcurDir¤@­P , ¨Ñ±z°Ñ¦Ò

TOP

¸É¤W¦bWin7 + Excel 2007ªº FileDialog ¤¶­±


³o¬OWinXP + Excel 2007 ªº FileDialog ¤¶­±


°ÝÃD·|¤£·|¥X¦b¨â­Ó¤¶­±©Ò±oªº¸ô®|¤£¦P¡A¥i¯à¤w¸g¤£¬O¥ÎInitialFileName¡A¤]¤£¬O¥ÎSelectedItems(1)©Ò¯à¨ú±oªº¸ô®|¤F¡A¬O¤£¬OÁÙ¦³¨ä¥¦ªº¤èªk¨ú±o³o¼Ëªº¸ô®|©O¡HÁÂÁ¡I

TOP

¦^´_  maiko
1#°Ý»¡:  2003  d:\SaveExcel\20121009 ¥i¬O¦b2007®É®³¨ìªº¸ô®|¬O¡Gd:\SaveExcel\
§Úªº¦^ÂÐ ...
GBKEE µoªí©ó 2012-10-9 17:16



   
§A»~·|¤F§Úªº·N«ä¤F¡A§Ú¨Ã¤£¬O­n¡u¹w³]Àɮצì¸m¡v©ÎªÌ­n§ïÅÜ¡u¹w³]Àɮצì¸m¡v¡A§Ú¬O·Q³q¹L¿ï¾ÜÀɮ׸ô®|µM«áµ¹¥X§¹¾ãªº¸ô®|¦r¦ê¡A¦p¡Gd:\SaveExcel\20121009\¡A³o¼Ëªº¦r¦ê¡A¦Ó§Ú¦b2003®É¡A¨Ï¥ÎInitialFileName¬O¥i¥H§¹¾ãªº¨ú±oÀɮ׸ô®|¡Gd:\SaveExcel\20121009\¡A¦Ó¦b2007®É¡A¨Ï¥ÎInitialFileName´N¥u¯à¨ú±o¡Gd:\SaveExcel\¡A´N¬O®t¤F¤@¼h¸ô®|¡C

¦Ó§Ú¥Îstillfish00¤j´£¨Ñªº¨ú±oªºÀɮ׸ô®|«o¬O¡Gd:\SaveExcel\20101009¡A«á­±¤Ö¤F¡u\¡v³o­Ó¡A¥¿¬O³o¼Ëªº§xÂZ¤~°Ý³o¸Ìªº°ª¤â¬Ý¬Ý¦³¤°»ò¤èªk¸Ñ¨M§¹¾ã¸ô®|¦r¦êªº°ÝÃD¡AÁÂÁ¡I

½Ð¥Î¥N½X¦bExcel¤W¸Õ¸Õ¡CÁÂÁ¡I

TOP

¦^´_ 5# maiko
1#°Ý»¡:  2003  d:\SaveExcel\20121009 ¥i¬O¦b2007®É®³¨ìªº¸ô®|¬O¡Gd:\SaveExcel\
§Úªº¦^ÂÐ ¬O«ü¥X¥i¯à¬O Application.DefaultFilePath   2003,2007 ªº¡u¹w³]Àɮצì¸m¡v ¸ô®|¤£¦P
§A°Ý :      InitialFileName¥u¬O¶}±ÒDialog®É¤@¶}©lªº¦ì¸m ´N¬O¡u¹w³]Àɮצì¸m¡v
                ©Ò¥H¦b¶}±ÒDialog®É¤w¸g§ïÅܤFÀɮצì¸m¡A©Ò¥H«ö¤F½T©w¥H«á©Ò±o¨ìªº¸ô®|¤w¸g¤£¬O¡u¹w³]Àɮצì¸m¡vªº¸ô®|¡C
¬O¹ïªº
  1. Sub Ex()
  2.     Application.DefaultFilePath = "D:\TEST"
  3.     '¥i­×§ï¡u¹w³]Àɮצì¸m¡v
  4. End Sub
½Æ»s¥N½X

TOP

½Ð¦U¦ì°ª¤â¥Î¥N½X¸Õ¸Õ¬Ý¡A­þ¸Ì¥X¿ù¤F¡H¦³¤°»ò¦a¤è­n§ï¶i¡HÁÂÁ¡I

TOP

¦^´_  maiko
2# »¡ InitialFileName¥u¬O§A¶}±ÒDialog®É¤@¶}©lªº¦ì¸m
¹w³]¦p¹Ï
GBKEE µoªí©ó 2012-10-9 15:33



   

1. §Aªº·N«ä¬O¤£¬O»¡¦b¿ï¶µ¤¤ªº¡u¹w³]Àɮצì¸m¡v¨S¦³¡u\¡v¡A¨º»ò¨ú±oªº¸ô®|³Ì«á­±´N¨S¦³¡u\¡v¡H

2. ÁÙ¬O»¡InitialFileName¥u¬O¶}±ÒDialog®É¤@¶}©lªº¦ì¸m ´N¬O¡u¹w³]Àɮצì¸m¡v¡H

¦pªG¬O1.ªº¸Ü¡A¨º»ò§Ú¦bWinXP + Excel 2007¡A¥ÎInitialFileName´N¥i¥H±o¨ì§¹¾ãªº¸ô®|¡A¦p¡Gd:\SaveExcel\20121009\
¦pªG¬O2.ªº¸Ü¡A¦]¬°¦b¶}±ÒDialog®É¤w¸g§ïÅܤFÀɮצì¸m¡A©Ò¥H«ö¤F½T©w¥H«á©Ò±o¨ìªº¸ô®|¤w¸g¤£¬O¡u¹w³]Àɮצì¸m¡vªº¸ô®|¡C

©¿µM¡A§Ú±o¨ì¤F¤@­Ó¦n¹³¸òWindows¦³Ãöªº°ÝÃD¡A´N¬O¡G
¥ÎWin7 + Excel 2007ªº¸Ü¡A¥Î.InitialFileName¨ú¨ìªº¸ô®|´N·|¤Ö¤@¼h¡F
¥ÎWinXP + Excel 2007ªº¸Ü¡A¥Î.InitialFileName¨ú¨ìªº¸ô®|´N«Ü§¹¾ã¡C
·íµMExcel 2003¦b­þ­ÓWindows³£¨S¦³°ÝÃD¡C

¤£ª¾¹D³o­Ó¬O¤£¬OWindows¥»¨­ªºFileDialog¤¶­±¤£¦P©Ò±o¨ìªº¸ô®|¤£¦P¡H
³o­Ó¬OWinXP + Excel 2007Â^¨úªºFileDialog¤¶­±¡G


Win7 + Excel 2007¼È®ÉÂ^¨ú¤£¨ì¡Aµ¥¤U¦A¸É¤W¡C

TOP

¦^´_ 1# maiko
2# »¡ InitialFileName¥u¬O§A¶}±ÒDialog®É¤@¶}©lªº¦ì¸m
¹w³]¦p¹Ï

  1. Option Explicit
  2. Sub Ex() ' 2003, 2007 ¤À§O°õ¦æ¬Ý¬Ý¦³µL®t§O
  3.     MsgBox Application.DefaultFilePath
  4. End Sub
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : µoµÊ®ð¬Oµu¼ÈªºµoºÆ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD