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

[µo°Ý] ¶}±Ò¨Ã½s¿èÀÉ®×

[µo°Ý] ¶}±Ò¨Ã½s¿èÀÉ®×

¦U¦ì°ª¤â
¤p§Ì·Q°µ­ÓVBA¥¨¶°a.xlsm
¥\¯à¬O¶}±ÒD¼Ñªºb.xlsx(¨C¦¸ªºÀɦW¤£¤@¼Ë) ¨Ó°µ­«½Æ©Êªº¨Æ±¡
¦ý¬O§Ú¥d¦b¡A§Ú¥´¶}¤Fb.xlsx¡AµM«á§Ú¤£¾å±o¸Ó«ç»òÅýµ{¦¡ª¾¹D¡A§Ú­n½s¿èªº¬Ob.xlsx¡A
¤ñ¦p §Ú­nÅýb.xlsxªº cells(1,1) = abc
³o¨Çµ{¦¡¸Ó«ç»ò©ñ¦b­þ?
ÁÂÁ¦U¦ì°ª¤â
  1. Option Explicit
  2. Dim Open_File As Object
  3. Sub ¶}±Ò¨Ã½s¿èÀÉ®×()
  4.     Set Open_File = Application.FileDialog(msoFileDialogOpen)
  5.     With Open_File
  6.          .InitialFileName = "D:\*.xlsx"
  7.          .Show
  8.     End With
  9. End Sub
½Æ»s¥N½X

¦^´_ 3# n7822123


    ¦¨¥\¤F
   ÁÂÁÂ!

TOP

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-7-29 02:14 ½s¿è

¦^´_ 1# ssooi


¿ïÀɲÄ2ºØ¼gªk¡A¬Ý§A³ßÅw­þ¤@­Ó

§Ú¬O³ßÅw²Ä1­Ó¡A¥\¯à(°Ñ¼Æ)¤ñ¸û¦h¡AÁÙ¥i¥H§ï¿ï¸ê®Æ§¨

¥Ñ¨ä³ßÅw¼g¦¨°Æ¨ç¼Æ¡A¥i¥Hµ¹¦h­Óµ{§Ç©I¥s¨Ï¥Î


Sub ¶}±Ò¨Ã½s¿èÀÉ®×()
Dim MyFile As String
MyFile = Application.GetOpenFilename("ExcelÀÉ®×,*.xls*", MultiSelect:=False)
If MyFile = "False" Then Exit Sub
With Workbooks.Open(MyFile).Sheets(1)
  .Activate
  .Cells(1, 1) = "abc"
  '.Parent.Close True       'Ãö³¬ÀÉ®×+¦sÀÉ
End With
End Sub
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

¥»©«³Ì«á¥Ñ n7822123 ©ó 2020-7-29 01:56 ½s¿è

¦^´_ 1# ssooi


§â¿ïÀÉ°µ¦¨°Æ¨ç¼Æ¡A°õ¦æ"¶}±Ò¨Ã½s¿èÀÉ®×" §Y¥i

¥þ³¡¤Wµù¸Ñ¤F¡A¦Û¦æ¬ã¨s¡Aµ{¦¡¦p¤U


Sub ¶}±Ò¨Ã½s¿èÀÉ®×()
With Workbooks.Open(GetFileFullName).Sheets(1)
  .Activate
  .Cells(1, 1) = "abc"
  '.Parent.Close True       'Ãö³¬ÀÉ®×+¦sÀÉ
End With
End Sub

Function GetFileFullName() As String
With Application.FileDialog(msoFileDialogFilePicker)
  .Filters.Clear                                              '¥ý²M°£¥i¿ïÀɮײM³æ
  .Filters.Add "ExcelÀÉ®×", "*.xls*"             '­­©w¿ï¨úÀɮתº²M³æ
  .InitialFileName = "D:\"                           '¿ï¨úµøµ¡³Ìªìªº¸ê®Æ§¨¦ì¸m
  .AllowMultiSelect = False                       '³æ¿ï
  If .Show = 0 Then Exit Function             '¨S¿ï¾Ü´NÂ÷¶}
  GetFileFullName = .SelectedItems(1)   '¦^¶Ç¿ï¾Üªº²Ä¤@­ÓÀɮתº '§¹¾ã¸ô®|'
End With
End Function
µ{¦¡¬O¨Ì»Ý¨D¼gªº¡A»Ý¨Dªí¹F¤£²M·¡
©ÎªÌ¨S¦³¤W¶Çªþ¥ó¡A·R²ö¯à§U

TOP

        ÀR«ä¦Û¦b : ¯¸¦b¥b¸ô¡A¤ñ¨«¨ì¥Ø¼Ð§ó¨¯­W¡C
ªð¦^¦Cªí ¤W¤@¥DÃD