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

°»´ú"1.xls"ÀɬO§_§e¥´¶}ª¬ºA?

°»´ú"1.xls"ÀɬO§_§e¥´¶}ª¬ºA?

½Ð±Ð¦U¦ì¤j¤j:
        ­Ó¤H¦b¥ÎVBA¥´¶}¥t¥~ExcelÀɦp"1.xls"ÀÉ,­Y³{"1.xls"ÀÉ¥»¨Ó´N¤w§e¥´¶}ª¬ºA®É,´N¤£¤Ó«ê·í¡C
½Ð±Ð¦U¦ì¥ý¶i­Y­n°»´ú"1.xls"ÀɬO§_§e¥´¶}ª¬ºA?À³¦p¦ó¹B¥ÎVBA»yªk?

  1. bookname = "1.xls"

  2. For Each wbs In Workbooks
  3.     If UCase(wbs.Name) = UCase(bookname) Then
  4.         MsgBox bookname & " is opened"
  5.         Exit For
  6.     End If
  7. Next wbs
½Æ»s¥N½X
¥uÀ´³o­Ó¡A§Æ±æ¥i¥HÀ°¨ì§A

TOP

¦^´_ 2# ¤p«L«È

·s¶}ÀÉ®× BOOK1 ´ú¸Õ¤£¥X¨Ó
ÂÂÀÉ®× S.XLS ´N¥i¥H´ú¸Õ¥X¨Ó
¦n¹³­n¦sÀÉ«á¤~¦³®Ä
{...} ªí¥Ü»Ý­n¥Î CTRL+SHIFT+ENTER ¤TÁä¿é¤J¤½¦¡

TOP

¥»©«³Ì«á¥Ñ Hsieh ©ó 2012-8-31 22:32 ½s¿è

¦^´_ 3# ML089


    ³o­Ó°ÝÃD²o¯A¨ì¶}±ÒÀɮ׬O§_¬O¦b¦P¤@­ÓApplication
¦pªG¤w±Ò°Ê¤@­Ó¥þ·sªºExcelµM«á¶}±Ò¨ä¥LÀÉ®×
¨º»ò¦P¤@­ÓApplication©Ò¶}±ÒªºÀɮ׳£¯à§ä±o¨ì
¦ý¬O°²¦p¶}±Ò¤F¤@¨ÇÂÂÀÉ¡AµM«á«ö¤Uµ{¦¡¶°¸ÌªºExcelµ{¦¡
¦b³o­Ó·sªºÀɮפº«hµLªk·j´M¨ì¤§«e¶}±ÒªºÀɮצWºÙ
¥²¶·¬O¦b¤w¸g¶}±Òªºµ{¦¡¤¤
¥HÀÉ®×/¶}·sÀɮפ~¯à°÷·j´M©Ò¦³¤w¶}±ÒÀÉ®×
FilesExists.rar (7.6 KB)
play.gif
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 4# Hsieh


   
¹ï¤£°_¡A­J¶Ã¦^µª¿ùªºµª®×¡A¤Q¤À©êºp:dizzy:

TOP

¦^´_ 5# ¤p«L«È

¤d¸U§O³o»ò»¡¡A°Q½×°Ï¨S¦³¯u¥¿¹ï»P¿ù
«i©óµoªí¤~¯àÀò±o§ó¦h
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¥»©«³Ì«á¥Ñ yangjie ©ó 2012-9-1 04:33 ½s¿è

¦^´_ 4# Hsieh
    ½Ð±Ð©óªO¥D¥ý¶i
    Dim Filt As String
    Dim FilterIndex As Integer
    Dim fileName As Variant
    Dim Title As String
    Filt = "Excel Files (*.xls),*.xls"
    FilterIndex = 5
    Title = "Select a File for Import"
    fileName = Application.GetOpenFilename _
        (FileFilter:=Filt, _
         FilterIndex:=FilterIndex, _
         Title:=Title)
    If fileName = False Then
        MsgBox "No file was selected."
        Exit Sub
    End If
§Ú¥u­n±o¨ìfileName ªºÀɦW(string)À³¦p¦ó¤U»yªk?(¤£§tpath)
ÁÂÁÂ

TOP

¦^´_ 7# yangjie ¥D­n

    ¥D­n¤U¤@¦C­nOpen
Set wb = Workbooks.Open(fileName, True, False)
   ¦ý±`¦b¤w¥´¶}¤§¤U°µ­«½Æ¥´¶}
¤£¤äÀ³¦p¦ó³B²z

TOP

¦^´_ 4# Hsieh
     Hseih¤j¤j     ÁÂÁ±z
Function IsOpen(Fs As String) As Boolean
IsOpen = False
For Each w In Windows
  If w.Caption = Fs Then IsOpen = True: Exit For
Next
End Function

    ¨ä¤¤ fs »P ¤W­zfilename «¬ºA¤£²Å §Ú´N¥d¦í¤F «ç»ò¿ì?

TOP

¦^´_ 4# Hsieh
¹ï¤£°_ ±N¤j¦W«÷¿ù¤F À³¬°Hsieh¤j¤j

TOP

        ÀR«ä¦Û¦b : ¡i°µ¤Hªº¶}©l¡j¨C¤@¤Ñ³£¬O¬G¤Hªº¶}©l¡A¨C¤@­Ó®É¨è³£¬O¦Û¤vªºÄµ±§¡C
ªð¦^¦Cªí ¤W¤@¥DÃD