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

µ{¦¡±Ò°Ê®É¡A¾Ü¤@¶}±Ò¥t¥~¨â­ÓÀÉ®×

µ{¦¡±Ò°Ê®É¡A¾Ü¤@¶}±Ò¥t¥~¨â­ÓÀÉ®×

µ{¦¡±Ò°Ê®É¡A¾Ü¤@¶}±Ò¥t¥~¨â­ÓÀÉ®×

½Ð°Ý¦p«O¶}±Òexcel «á¡A¦bPrivate Sub Workbook_Open() ¾Ü¤@¶}±ÒÀÉ®×

Private Sub Workbook_Open()
Workbooks.Open Filename:=ThisWorkbook.Worksheets("Sheet1").Range("B14").value

Workbooks.Open Filename:=ThisWorkbook.Worksheets("Sheet1").Range("B18").value
End Sub

¦pªG b14 ¦ì¸mªºÀÉ®×¥i¥H¶}±Ò¦¨¥\¡A´N¤£¶}±ÒB18ªºÀÉ®×

¦pªG b14 µLªk¶}±Ò¡A«h§ï¶}±Ò b18 ¡]¦pªG b18 ¤]µLªk¶}±Ò¡A«hÅã¥Ü msg "open file error" ¡^

½Ð°Ý¸Ó«ç»ò¼g¡H¡H «ç»ò¼g«ç»ò©Ç~~

        Set MyBook = Workbooks.Open Filename:=ThisWorkbook.Worksheets("°ò¥»¸ê®Æ").Range("B18").value

        On Error GoTo 0
        If MyBook Is Nothing Then
                Workbooks.Open Filename:=ThisWorkbook.Worksheets("°ò¥»¸ê®Æ").Range("B18").value
        End If         
               
        Else
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

  1. Private Sub Workbook_Open()
  2. dim fs as object, Sdir$
  3. set fs=createobject("Scripting.FileSystemObject")
  4. with thisworkbook.worksheets("°ò¥»¸ê®Æ")
  5.         if fs.FileExists(.Range("B14").value) then
  6.                 SDir = .range("B14").value
  7.         else if fs.FileExists(.Range("B18").value) then
  8.                 SDir = .range("B14").value
  9.         else
  10.                 msgbox "Open file error"
  11.         end if
  12.         Set MyBook = Workbooks.Open Filename:=
  13. end sub
½Æ»s¥N½X

TOP

¦^´_ 2# prin.huang


    «D±`·PÁ¡A§Ú­è­è­«·s­×§ï§Úªº¨t²Î¡A²×²×¥i¥H¥¿±`¹B§@¤F¡A¤Q¤À·PÁ§Aªº¨ó§U~~~
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

TOP

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