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

[µo°Ý] ¦p¦ó³z¹L VBA»yªk ¶}±Ò±M®×ªº±K½X

¦^´_ 7# jsleee


    #3ªºµ{§Ç´N¯à¸Ñ°£Âê©w
  1. Sub ¶}±ÒÀÉ®×()
  2.     Dim CurrentPath As String   'Àx¦s¥Ø«eÀɮץؿý
  3.     Dim OpenFN As String   'Ū¨ú¨ìªºÀɮצWºÙ
  4.     Dim FNExt As String    'ÀÉ®×°ÆÀɦW
  5.     Dim MyBook As Workbook
  6.     FN = ActiveWorkbook.Name

  7.     CurrentPath = Range("B1")   '¦pªG¦³³]©w¥H³]©w¬°¥D
  8.     FNExt = Range("b2")   '¬d¸ßÀÉ®×Ãþ«¬
  9.     If Trim(CurrentPath) = "" Then
  10.        CurrentPath = Excel.ActiveWorkbook.Path
  11.     End If
  12.    
  13.     n = 0
  14.     Sheets("trans").Cells.Delete  '±N¤§«eªºµ²ªG²M°£
  15.     If Right(CurrentPath, 1) = "\" Then
  16.         OpenFN = Dir(CurrentPath & FNExt, vbDirectory)
  17.         OpenFNTime = CurrentPath
  18.     Else
  19.         OpenFN = Dir(CurrentPath & "\" & FNExt, vbDirectory)
  20.         OpenFNTime = CurrentPath & "\"
  21.     End If
  22.    
  23.     While OpenFN <> ""
  24.         If OpenFN <> ActiveWorkbook.Name Then '³o­ÓÀɮפ£­nÅã¥Ü
  25.             If OpenFN <> "." And OpenFN <> ".." Then
  26.                 n = n + 1
  27.                 fs = OpenFNTime & OpenFN
  28.                 Sheets("trans").Cells(n, 7).Value = fs
  29.                 Workbooks.Open(Filename:=OpenFNTime & OpenFN _
  30.        , Password:="msign").RunAutoMacros Which:=xlAutoOpen
  31.        Set MyBook = ActiveWorkbook
  32.        UnprotectVBProj "password", MyBook '½Ð¦Û¦æ­×§ï±K½X
  33.             End If
  34.         End If
  35.         OpenFN = Dir() 'Ū¨ú¤U¤@­ÓÀÉ®×
  36.     Wend
  37.    
  38.     Workbooks(FN).Close savechanges:=False
  39. End Sub
  40. Sub UnprotectVBProj(ByVal Pwd As String, wb As Workbook)
  41.     Dim vbProj As Object
  42.     Set vbProj = wb.VBProject
  43.     If vbProj.Protection <> 1 Then Exit Sub ' already unprotected
  44.     Set Application.VBE.ActiveVBProject = vbProj
  45.     SendKeys Pwd & "~~"
  46.     Application.VBE.CommandBars(1).FindControl(ID:=2578, recursive:=True).Execute
  47. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

  1. Sub ¶}±ÒÀÉ®×()
  2.     Dim CurrentPath As String   'Àx¦s¥Ø«eÀɮץؿý
  3.     Dim OpenFN As String   'Ū¨ú¨ìªºÀɮצWºÙ
  4.     Dim FNExt As String    'ÀÉ®×°ÆÀɦW
  5.     Dim MyBook As Workbook
  6.     FN = ActiveWorkbook.Name

  7.     CurrentPath = Range("B1")   '¦pªG¦³³]©w¥H³]©w¬°¥D
  8.     FNExt = Range("b2")   '¬d¸ßÀÉ®×Ãþ«¬
  9.     If Trim(CurrentPath) = "" Then
  10.        CurrentPath = Excel.ActiveWorkbook.Path
  11.     End If
  12.    
  13.     n = 0
  14.     Sheets("trans").Cells.Delete  '±N¤§«eªºµ²ªG²M°£
  15.     If Right(CurrentPath, 1) = "\" Then
  16.         OpenFN = Dir(CurrentPath & FNExt, vbDirectory)
  17.         OpenFNTime = CurrentPath
  18.     Else
  19.         OpenFN = Dir(CurrentPath & "\" & FNExt, vbDirectory)
  20.         OpenFNTime = CurrentPath & "\"
  21.     End If
  22.    
  23.     While OpenFN <> ""
  24.         If OpenFN <> ActiveWorkbook.Name Then '³o­ÓÀɮפ£­nÅã¥Ü
  25.             If OpenFN <> "." And OpenFN <> ".." Then
  26.                 n = n + 1
  27.                 fs = OpenFNTime & OpenFN
  28.                 Workbooks(FN).Sheets("trans").Cells(n, 7).Value = fs
  29.                 Workbooks.Open(Filename:=OpenFNTime & OpenFN _
  30.        , Password:="msign").RunAutoMacros Which:=xlAutoOpen
  31.        Pwd = "1234" '¦Û¦æ­×§ï±K½X
  32.        SendKeys Pwd & "~"
  33.        Application.CommandBars(16).FindControl(ID:=1561, recursive:=True).Execute
  34.             End If
  35.         End If
  36.         OpenFN = Dir() 'Ū¨ú¤U¤@­ÓÀÉ®×
  37.     Wend
  38.    
  39.     Workbooks(FN).Close savechanges:=False
  40. End Sub
½Æ»s¥N½X
¦^´_ 11# jsleee
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 13# jsleee

³o¬O¦b2003ª©¤¤¥i¥H°õ¦æªºµ{¦¡½X
¤£¦Pª©¥»½Ð°õ¦æ¤U¦Cµ{¦¡½X
¨ú±o¹ïÀ³ID
  1. Sub nn()
  2. Dim cmb As CommandBar
  3. For Each cmb In Application.CommandBars
  4.    For Each ob In cmb.Controls
  5.    r = r + 1
  6.    Cells(r, 1).Resize(, 3) = Array(ob.Caption, cmb.Index, ob.ID)
  7.    Next
  8. Next
  9. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 15# jsleee
SendKeys¤èªk¥[¤Wwait°Ñ¼Æ¸Õ¸Õ¬Ý
  1. Sub ¶}±ÒÀÉ®×()
  2.     Dim CurrentPath As String   'Àx¦s¥Ø«eÀɮץؿý
  3.     Dim OpenFN As String   'Ū¨ú¨ìªºÀɮצWºÙ
  4.     Dim FNExt As String    'ÀÉ®×°ÆÀɦW
  5.     Dim MyBook As Workbook
  6.     FN = ActiveWorkbook.Name

  7.     CurrentPath = Range("B1")   '¦pªG¦³³]©w¥H³]©w¬°¥D
  8.     FNExt = Range("b2")   '¬d¸ßÀÉ®×Ãþ«¬
  9.     If Trim(CurrentPath) = "" Then
  10.        CurrentPath = Excel.ActiveWorkbook.Path
  11.     End If
  12.    
  13.     n = 0
  14.     Sheets("trans").Cells.Delete  '±N¤§«eªºµ²ªG²M°£
  15.     If Right(CurrentPath, 1) = "\" Then
  16.         OpenFN = Dir(CurrentPath & FNExt, vbDirectory)
  17.         OpenFNTime = CurrentPath
  18.     Else
  19.         OpenFN = Dir(CurrentPath & "\" & FNExt, vbDirectory)
  20.         OpenFNTime = CurrentPath & "\"
  21.     End If
  22.    
  23.     While OpenFN <> ""
  24.         If OpenFN <> ActiveWorkbook.Name Then '³o­ÓÀɮפ£­nÅã¥Ü
  25.             If OpenFN <> "." And OpenFN <> ".." Then
  26.                 n = n + 1
  27.                 fs = OpenFNTime & OpenFN
  28.                 Workbooks(FN).Sheets("trans").Cells(n, 7).Value = fs
  29.                 Workbooks.Open(Filename:=OpenFNTime & OpenFN _
  30.        , Password:="msign").RunAutoMacros Which:=xlAutoOpen
  31.        Pwd = "1234" '¦Û¦æ­×§ï±K½X
  32.        SendKeys Pwd & "~", True
  33.        Application.CommandBars(16).FindControl(ID:=1561, recursive:=True).Execute
  34.             End If
  35.         End If
  36.         OpenFN = Dir() 'Ū¨ú¤U¤@­ÓÀÉ®×
  37.     Wend
  38.    
  39.     Workbooks(FN).Close savechanges:=False
  40. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

¦^´_ 17# jsleee

¬O¬Y¨Ç©T©wÀÉ®×·|µo¥Í³o¼Ëªº±¡§Î¶Ü?
¦pªG¬O¡A§Ú²q¥i¯à¬OÀɮ׶}±Ò®É¶¡¸ûªø
µ²ªGµ{¦¡¥ý¶]¨ìÀ˵øµ{¦¡½X¡AµM«á¤~§¹¦¨Àɮ׶}±Ò
¸Õ¸Õ¥Îsleep°±¹y¼Æ¬í«á¦AÄ~Äò©¹¤U°õ¦æ¸Õ¸Õ¬Ý¬O§_¦³§ïµ½
  1. Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
  2. Sub ¶}±ÒÀÉ®×()
  3.     Dim CurrentPath As String   'Àx¦s¥Ø«eÀɮץؿý
  4.     Dim OpenFN As String   'Ū¨ú¨ìªºÀɮצWºÙ
  5.     Dim FNExt As String    'ÀÉ®×°ÆÀɦW
  6.     Dim MyBook As Workbook
  7.     FN = ActiveWorkbook.Name

  8.     CurrentPath = Range("B1")   '¦pªG¦³³]©w¥H³]©w¬°¥D
  9.     FNExt = Range("b2")   '¬d¸ßÀÉ®×Ãþ«¬
  10.     If Trim(CurrentPath) = "" Then
  11.        CurrentPath = Excel.ActiveWorkbook.Path
  12.     End If
  13.    
  14.     n = 0
  15.     Sheets("trans").Cells.Delete  '±N¤§«eªºµ²ªG²M°£
  16.     If Right(CurrentPath, 1) = "\" Then
  17.         OpenFN = Dir(CurrentPath & FNExt, vbDirectory)
  18.         OpenFNTime = CurrentPath
  19.     Else
  20.         OpenFN = Dir(CurrentPath & "\" & FNExt, vbDirectory)
  21.         OpenFNTime = CurrentPath & "\"
  22.     End If
  23.    
  24.     While OpenFN <> ""
  25.         If OpenFN <> ActiveWorkbook.Name Then '³o­ÓÀɮפ£­nÅã¥Ü
  26.             If OpenFN <> "." And OpenFN <> ".." Then
  27.                 n = n + 1
  28.                 fs = OpenFNTime & OpenFN
  29.                 Workbooks(FN).Sheets("trans").Cells(n, 7).Value = fs
  30.                 Workbooks.Open(Filename:=OpenFNTime & OpenFN _
  31.        , Password:="msign").RunAutoMacros Which:=xlAutoOpen
  32.        Sleep 200 '¼È°±2¬í
  33.        Pwd = "1234" '¦Û¦æ­×§ï±K½X
  34.        CId = IIf(Application.Version = 11, 16, 42)
  35.        Set vbProj = ActiveWorkbook.VBProject
  36.        If vbProj.Protection <> 1 Then GoTo 10
  37.        SendKeys Pwd & "~", True
  38.        Application.CommandBars(CId).FindControl(ID:=1561, recursive:=True).Execute
  39.             End If
  40.         End If
  41. 10
  42.         OpenFN = Dir() 'Ū¨ú¤U¤@­ÓÀÉ®×
  43.     Wend
  44.     SendKeys "%{F11}" 'Â÷¶}VBE
  45.    ' Workbooks(FN).Close savechanges:=False
  46. End Sub
½Æ»s¥N½X
¾Ç®üµL²P_¤£®¢¤U°Ý

TOP

        ÀR«ä¦Û¦b : ¬Ý§O¤H¤£¶¶²´¡A¬O¦Û¤v­×¾i¤£°÷¡C
ªð¦^¦Cªí ¤W¤@¥DÃD