±³À°°úÁ¤ ³ªÀÇÇнÀ ¿ÀÇǽºÆÁ °Ë»ö ¹«·á°­ÁÂ
Home ·Î±×ÀΠȸ¿ø°¡ÀÔ °í°´¼¾ÅÍ »çÀÌÆ®¸Ê
¿ÀÇǽºÆ©ÅÍ ±â¾÷ASP¼­ºñ½º > ¹«·á°­ÁÂ
¿¢¼¿ 2000 µû¶óÇϱâ
Ȩ·¯´× ¿¢¼¿ 2000°­ÁÂ
À繫 ÇÔ¼ö °­ÁÂ
¿¢¼¿ 2002 »õ·Î¿î ±â´É
Ȳ±â¼º´ÔÀÇ VBA°­ÁÂ
°û½ÂÁÖ´ÔÀÇ VBAÀ̾߱â
Home > ¹«·á°­Á > ¿¢¼¿
¿¢¼¿, °û½ÂÁÖ´ÔÀÇ ¿ÀÆ©°ø±¸ÇÔ Á¦ÀÛÀ¸·Î ¹è¿öº¸´Â VBA À̾߱â, Excel
  

18. ¼¼ °¡Áö ÅëÇÕ ¹®¼­ °ü·Ã ¸ÅÅ©·Î

ÀÚ·á´Ù¿î·Îµå : ¿ÀÆ©°ø±¸ÇÔ018.xls 

¾È³çÇϼ¼¿ä. ¿À´ÃÀº ÅëÇÕ¹®¼­¿Í °ü·ÃÇÑ ³× °¡ÁöÀÇ ¸ÅÅ©·Î¸¦ ¼Ò°³ÇÒ Â÷·ÊÀÔ´Ï´Ù. º¸½Ã¸é ¾Ë°ÚÁö¸¸ »ç½Ç µûÁö°í º¸¸é µÎ °¡Áö ÀÔ´Ï´Ù. ¸ðµç ÅëÇÕ¹®¼­¸¦ ´Ý´Â °æ¿ì À̸¦ ÀÚµ¿À¸·Î ÀúÀåÇÒÁö ¾Æ´Ï¸é ¸ðµÎ ÀúÀåÇÏÁö ¾ÊÀ» °ÍÀÎÁö, ÀÏÀÏÀÌ »ç¿ëÀÚÀÇ È®ÀÎÀ» ¹ÞÀ» °ÍÀÎÁö¸¦ ¸¸µé¾î º¸¾Ò½À´Ï´Ù. ±â´ÉÀÌ Á¶±Ý¾¿ ´Ù¸¥ ¸¸Å­ Äڵ嵵 Á¶±Ý¾¿ ´Ù¸¨´Ï´Ù(ÇÙ½ÉÀº °°Áö¸¸)

ÄÚµå´Â ´ÙÀ½°ú °°½À´Ï´Ù.
¡®¸ðµç ÅëÇÕ¹®¼­¸¦ ÀúÀåÇÏ°í ´Ý´Â ÇÁ·Î½ÃÁ®
Sub AllCloseWithSaving()
     Dim wbk       As Workbook

     Application.DisplayAlerts = False
°¢Á¾ ¿¢¼¿ÀÇ °æ°í¸Þ½ÃÁö¸¦ º¸ÀÌÁö ¾Êµµ·Ï ÇÕ´Ï´Ù. À̸¦ False·Î ÇÏ´Â ÀÌÀ¯´Â ÀúÀåÇÏ°í ´Ý´Â °úÁ¤¿¡¼­ ÇÊ¿ä¾ø´Â ¸Þ½ÃÁö°¡ ³ª¿À´Â °ÍÀ» ¸·±â À§ÇÑ °ÍÀÔ´Ï´Ù.
     For Each wbk In Application.Workbooks
          If Not (wbk Is ThisWorkbook) Then
               wbk.Save
ÅëÇÕ¹®¼­¸¦ ÀúÀåÇÕ´Ï´Ù.
               wbk.Close
ÅëÇÕ¹®¼­¸¦ ´Ý½À´Ï´Ù.
          End If
     Next
     Application.DisplayAlerts = True
End Sub

¡®¸ðµç ÅëÇÕ¹®¼­¸¦ ÀúÀåÇÏÁö ¾Ê°í ´Ý´Â ÇÁ·Î½ÃÁ®
Sub AllCloseWithoutSaving()
     Dim wbk As Workbook

     Application.DisplayAlerts = False
     For Each wbk In Application.Workbooks
          If Not (wbk Is ThisWorkbook) Then
               wbk.Saved = True
ÀúÀå¿©ºÎ¸¦ True·Î ÁÜÀ¸·Î½á ÅëÇÕ¹®¼­°¡ ÀúÀåµÈ °Íó·³ ÇÕ´Ï´Ù. ÀÌ·¸°Ô ´Ý´Â °æ¿ì(Close)½ÇÁ¦·Î ÀúÀåÇÏÁö ¾Ê°í ´Ý´Â °á°ú°¡ µË´Ï´Ù.

               wbk.Close
          End If
     Next
     Application.DisplayAlerts = True
End Sub

¡®¸ðµç ÅëÇÕ¹®¼­¸¦ »ç¿ëÀÚÀÇ È®ÀÎÀ» ¹Þ°í ÀúÀå ¶Ç´Â ±×³É ´Ý´Â ÇÁ·Î½ÃÁ®
Sub AllCloseWithConfirm()
     Dim wbk As Workbook

     Application.DisplayAlerts = True
ÀÏÀÏÀÌ »ç¿ëÀÚÀÇ È®ÀÎÀ» ¹Þ°í ´ÝÀ¸·Á´Â °æ¿ì DisplayAlerts¼Ó¼ºÀ» True·Î ÇÕ´Ï´Ù.
     For Each wbk In Application.Workbooks
          If Not (wbk Is ThisWorkbook) Then
               wbk.Close
          End If
     Next
End Sub

À§ÀÇ Äڵ带 º¸½Ã¸é ´ÙÀ½°ú °°Àº °øÅëµÈ ·çƾÀÌ ÀÖ½À´Ï´Ù.
For Each wbk In Application.Workbooks
     If Not (wbk Is ThisWorkbook) Then
          ...
     End If
Next
wbk¶ó´Â Workbook°³Ã¼º¯¼ö¸¦ ¼±¾ðÇÏ°í Application.Workbooks Ä÷º¼ÇÀ» ·çÇÁµ¹¸é¼­ WorkbookÀ» ´Ý½À´Ï´Ù. À̶§ ´ÝÀ¸·Á´Â ÅëÇÕ¹®¼­°¡ ¿ÀÆ©°ø±¸ÇÔ(ThisWorkbook)ÀÌ ¾Æ´Ï¸é ´Ý½À´Ï´Ù. ÀÌ °³Ã¼°¡ Àú °³Ã¼¿Í °°Àº °ÍÀÎÁö¸¦ È®ÀÎÇÏ´Â ¿¬»êÀÚ´Â ¿©·¯ºÐµé¿¡°Ô Àͼ÷ÇÑ ¡®=¡¯ÀÌ ¾Æ´Ï¶ó IsÀÔ´Ï´Ù. µµ¿ò¸»À» º¸¸é Is¿¡ ´ëÇØ ´ÙÀ½°ú °°ÀÌ ¼³¸íÇÏ°í ÀÖ½À´Ï´Ù.

Is ¿¬»êÀÚ
µÎ °³Ã¼°¡ °¡¸®Å°´Â º¯¼ö°¡ µ¿µîÇÑÁö¸¦ ºñ±³ÇÕ´Ï´Ù.
result = object1 Is object2
Is ¿¬»êÀÚ ±¸¹®Àº ´ÙÀ½°ú °°Àº ±¸¼º ¿ä¼Ò·Î µÇ¾î ÀÖ½À´Ï´Ù.

Is ¿¬»êÀÚ ¿¹Á¦
¾Æ·¡ ¿¹Á¦¿¡¼­´Â Is ¿¬»êÀÚ¸¦ »ç¿ëÇÏ¿© µÎ °³ÀÇ °³Ã¼ ÂüÁ¶¸¦ ºñ±³ÇÕ´Ï´Ù. °³Ã¼ º¯¼ö À̸§Àº ÀϹÝÀûÀÎ À̸§À̸ç, ¿¹¸¦ µé±â À§Çؼ­¸¸ »ç¿ëÇÕ´Ï´Ù.

Dim MyObject, YourObject, ThisObject, OtherObject, ThatObject, MyCheck
Set YourObject = MyObject ' °³Ã¼ ÂüÁ¶¸¦ ÁöÁ¤ÇÕ´Ï´Ù.
Set ThisObject = MyObject
Set ThatObject = OtherObject

MyCheck = YourObject Is ThisObject ' True¸¦ ¹ÝȯÇÕ´Ï´Ù.
MyCheck = ThatObject Is ThisObject ' False¸¦ ¹ÝȯÇÕ´Ï´Ù.

' MyObject¸¦ °¡Á¤ÇÕ´Ï´Ù <> OtherObject
MyCheck = MyObject Is ThatObject

À̹ø¿£ ÇöÀçÀÇ ÅëÇÕ ¹®¼­¸¦ ¹ÙÅÁÈ­¸é¿¡ ¹Ù·Î °¡±â Å°¸¦ ¸¸µå´Â ÇÁ·Î½ÃÁ®¸¦ ¸¸µé¾î º¼ Â÷·ÊÀÔ´Ï´Ù. ¹ÙÅÁÈ­¸é¿¡ ¹Ù·Î °¡±â Å°¸¦ ¸¸µå´Â ±â´ÉÀº VBA³ª ¿¢¼¿¿¡ ¾ø´Â ±â´ÉÀÔ´Ï´Ù. ´«Ä¡°¡ ºü¸¥ ºÐµéÀº ÁüÀÛÇϽðÚÁö¸¸ WSH(Windows Script Host)¶ó´Â °³Ã¼¸¦ ÂüÁ¶ÇØ¾ß ÇÕ´Ï´Ù. (ÂüÁ¶¸¦ ÀÌ°Í Àú°Í ÇÏ´Ù º¸´Ï ÂüÁ¶°¡ ±úÁö°Å³ª ÇÁ·ÎÁ§Æ®°¡ ¹«°Å¿öÁö´Â ´À³¦ÀÌ ÀÖ½À´Ï´Ù. °³ÀÎÀûÀ¸·Î »ç¿ëÇÒ ¸ñÀûÀ̶ó¸é ÂüÁ¶°¡ ¸¹¾Æµµ »ó°ü¾øÁö¸¸ »ó¿ëÀÎ °æ¿ì µÇµµ·Ï ÂüÁ¶¸¦ ÁÙ¿©¾ß ¿¡·¯È®·üÀÌ ÀûÀ» °ÍÀÔ´Ï´Ù)

Á¦°¡ ÀÌ ³¸¼± WSH¸¦ ¼Ò°³ÇÏ´Â ÀÌÀ¯´Â ¿ÀÇǽº¿Í °ü·ÃÇÏ¿© ¸¹Àº ÀÏÀ» ÇÒ ¼ö ÀÖÀ» °Í °°¾Æ º¸¿©¼­ÀÔ´Ï´Ù( ¿ª½Ã ´É¼÷ÇÏ°Ô WSH¸¦ »ç¿ëÇϴ óÁö´Â ¾Æ´Õ´Ï´Ù )
¸ÕÀú WSH¿¡ ´ëÇÑ °³¿ä¸¦ ¸»¾¸ µå¸®´Â °ÍÀÌ ¼ø¼­ÀÏ °Í °°±º¿ä. ´ÙÀ½Àº Á¦°¡ ¿¹Àü¿¡ ½áµÐ WSH¿¡ ´ëÇÑ ±ÛÀ» ¿Å±ä °ÍÀÔ´Ï´Ù.

 
¹øÈ£ #3 /7 ³¯Â¥ 2001³â1¿ù8ÀÏ(¿ù¿äÀÏ) 13:50:53
À̸§ °û½ÂÁÖ Á¦¸ñ [WSH] ¾ÆÁ÷ »ý¼ÒÇÑ WSH

WSH¶ó´Â ´Ü¾î¸¦ µé¾î º¸½Å Àû ÀÖ³ª¿ä? ¿À´ÃÀº ¾ÆÁ÷ »ý¼ÒÇÑ ´À³¦ÀÌ ÀÖÁö¸¸ ÇâÈÄ À©µµ¿ì ÇÁ·Î±×·¡¹ÖÀÇ °¨ÃÊ¿ªÇÒÀ» ÇÒ °ÍÀ¸·Î ±â´ëµÇ´Â WSH(Windows Script Host,ÀÌÇÏ WSH)¿¡ ´ëÇØ Á¦°¡ ¾Æ´Â´ë·Î Àû¾î º¼±î ÇÕ´Ï´Ù.

WSH´Â VB½ºÅ©¸³Æ®, J½ºÅ©¸³Æ®µîÀ» »ç¿ëÇÏ¿© À©µµ¿ì¿Í À©µµ¿ì ¾ÖÇø®ÄÉÀ̼ÇÀÇ ¿ÀºêÁ§Æ®¸ðµ¨¿¡ Á¢±ÙÇÒ ¼ö ÀÖ´Â ¾ð¾îÁ߸³È¯°æÀÔ´Ï´Ù. Áï ¾ð¾î´Â ¾Æ´ÏÁö¸¸ Áö¿øÇÏ´Â ¾ð¾î°¡ ½ÇÇà°¡´ÉÇÏ°Ô ¸¸µé¾î ÁÖ´Â ¿ªÇÒÀ» ÇÕ´Ï´Ù.

ÀÌ·± ºÎºÐµéÀº NT°è¿­ÀÇ OS¿¡¼­ À¥¾ÖÇø®ÄÉÀ̼ÇÀ» ¸¸µé ¶§ »ç¿ëÇÏ´Â ASP¿Í ºñ½ÁÇÑ °Í °°±º¿ä. ¾Æ¹¸Æ° ÀÎÅͳÝÀͽºÇ÷η¯, ¿¢¼¿, ¸Þ¸ðÀå µî ÀÚµ¿È­ÀÎÅÍÆäÀ̽º¸¦ °¡Áø ¾ÖÇø®ÄÉÀ̼ÇÀº WSH¸¦ ÅëÇØ Á¦¾îÇÒ ¼ö ÀÖ½À´Ï´Ù.

À¯´Ð½º¿¡´Â ½©½ºÅ©¸³Æ®, ¸ÆOS¿¡´Â ¾ÖÇýºÅ©¸³Æ®, µµ½º¿¡´Â ¹èÄ¡ÆÄÀÏÀÌ ÀÖÁö¸¸ ±×µ¿¾È À©µµ¿ì¿¡´Â ÀÚüÀûÀÎ ½ºÅ©¸³Æ®¾ð¾î°¡ ¾ø¾ú½À´Ï´Ù. Á¦ °³ÀÎÀûÀ¸·Î´Â ¸Ó³ª¸Õ µµ½º½ÃÀý¿¡ 4DOS¼¿À» °¡Áö°í ÆÄÀÏÀ» °ü¸®ÇÏ´Â ¹èÄ¡ÆÄÀÏÀ» ¸¸µé¾î º» ÀûÀÌ ÀÖ¾úÁÒ. ±× ´ç½Ã¿£ ³ëÅÏÄ¿¸Ç´õ¸¦ Èä³»³»·Á°í ¹«ÁøÀå ¾Ö¸¦ ½è½À´Ï´Ù. ÀÌÁ¦ À©µµ¿ì¿¡¼­ ±×º¸´Ù ´õ °­·ÂÇÑ WSH°¡ »ý°å½À´Ï´Ù. µµ½ºÀÇ ¹èÄ¡ÆÄÀÏÀº Á¦¾îÇÒ ¼ö ÀÖ´Â ±â´ÉÀÌ Á¦ÇÑÀûÀÌÁö¸¸ WSH´Â ½Ã½ºÅÛ·¹º§±îÁö Á¢±ÙÇÒ ¼ö ÀÖ½À´Ï´Ù.

WSH¿¡ ´ëÇØ ÀÚ¼¼È÷ ¾Ë°í ½ÍÀ¸½Å ºÐµéÀº ¸¶ÀÌÅ©·Î¼ÒÇÁÆ®»çÀÇ È¨ÆäÀÌÁö(http://www.microsoft.com/korea/ntserver/management/
Techdetails/TechSpecs/WSH.asp
)¸¦ ¹æ¹®Çغ¸½Ã±æ ¹Ù¶ø´Ï´Ù. ÇÁ·Î±×·¥Àº (http://www.microsoft.com/msdownload/vbscript/scripting.asp)¿¡¼­ ´Ù¿î ¹ÞÀ¸¼Åµµ µÅÁö¸¸ ÇöÀç »ç¿ëÁßÀÎ OS°¡ windows98,WindowsNT4.0(Option Pack4°¡ ¼³Ä¡µÈ), Windows2000À̶ó¸é WSH°¡ ÀÌ¹Ì ¼³Ä¡µÇ¾î ÀÖÀ» °Ì´Ï´Ù.

¾î¶»½À´Ï±î? WSH¿¡ ´ëÇØ ¾î´À Á¤µµ °¨À» ÀâÀ¸¼Ì³ª¿ä? ´ÙÀ½Àº WSH°³Ã¼¸¦ »ç¿ëÇÏ¿© ¹Ù·Î°¡±âÅ°¸¦ ¸¸µå´Â ÇÔ¼ö¸¦ ¼Ò°³ÇÕ´Ï´Ù.

Function CreateShortcutOnDesktop(strFullFilePathName As String) As Long

    Dim WSHShell       As IWshRuntimeLibrary.WSHShell
WSHShell¸¦ WSHShell °³Ã¼º¯¼ö·Î ¼±¾ðÇÏ¿´½À´Ï´Ù.
     Dim WSHShortcut      As IWshRuntimeLibrary.IWshShortcut_Class
IWshShortcut_Class°³Ã¼´Â ¹Ù·Î°¡±â¾ÆÀÌÄÜÀ» À§ÇÑ °³Ã¼ÀÔ´Ï´Ù.

     Dim strDesktopPath As String
     Dim strFileName As String
     Dim strPath As String

     On Error GoTo fCreateShortcutOnDesktop_Err

     ' Create a Windows Shell Object


¿©±â¿¡¼­´Â WSHShell °³Ã¼º¯¼ö¿¡ °³Ã¼¸¦ ÀúÀåÇÏ´Â ºÎºÐÀÔ´Ï´Ù. ±×·±µ¥ ¹®Á¦°¡ Çϳª ÀÖ´õ±º¿ä WSH°¡ ¹öÀüÀÌ ¹Ù²î¸é¼­ °³Ã¼¸ðµ¨ÀÌ º¯°æµÈ °Í °°´õ±º¿ä. ±×·¡¼­ WSH ¹öÀüÀÌ 1.0ÀÎ °æ¿ì ´ÙÀ½°ú °°ÀÌ ÇÕ´Ï´Ù.
     Set WSHShell = New IWshRuntimeLibrary.IWshShell_Class
¾Æ´Ï¶ó¸é ´ÙÀ½°ú °°ÀÌ ÇÕ´Ï´Ù.
     Set WSHShell = New IWshRuntimeLibrary.WSHShell

     ' Get the file's name and path...
     strFileName = Dir(strFullFilePathName)
     strPath = Left(strFullFilePathName, _
          Len(strFullFilePathName) - Len(strFileName))

³Ñ°Ü¹ÞÀº ¸Å°³º¯¼ö¿¡¼­ ÆÄÀÏÀÇ À̸§°ú °æ·Î¸¦ ºÐ¸®ÇÏ¿© ÀúÀåÇÕ´Ï´Ù.

     ' Make sure file exists
     If Not Len(strFileName) = 0 Then

          ' Read desktop path using WshSpecialFolders object
          strDesktopPath = WSHShell.SpecialFolders.Item("Desktop")
WSHShell°³Ã¼¿¡¼­ ½ºÆä¼ÈÆú´õÁß ÇϳªÀÎ ¹ÙÅÁÈ­¸éÀ» À̸§À» ¾ò½À´Ï´Ù.

          ' Create a shortcut object on the desktop
          Set WSHShortcut = WSHShell.CreateShortCut _
              (strDesktopPath & "\" & strFileName & ".lnk")

±× ¹ÙÅÁ È­¸é À̸§¿¡ ÆÄÀÏÀ̸§ + ¡°.lnk¡±¸¦ ºÙ¿© ¹Ù·Î °¡±â Å° ÆÄÀÏÀ» ¸¸µì´Ï´Ù. À©µµ¿ìŽ»ö±â¸¦ À¯½ÉÈ÷ º¸½Å ºÐµéÀº ¾Æ½Ã°ÚÁö¸¸ ¹ÙÅÁÈ­¸éÀÇ °¢Á¾ ¾ÆÀÌÄÜÀº Æú´õ¿¡ lnkÆÄÀÏ·Î ÀúÀåµÇ¾î ÀÖ½À´Ï´Ù. À©µµ¿ì¹öÀü¿¡ µû¶ó ÀúÀåµÇ´Â Æú´õÀ§Ä¡´Â ´Ù¸¨´Ï´Ù. °¡·É Win9x¹öÀüÀÎ °æ¿ì ¡°\Windows\¹ÙÅÁ È­¸é¡± À̶ó´Â Æú´õ¿¡ ÀúÀåµÇ°í Win2KÀÎ °æ¿ì ¡°\Documents and Settings\·Î±×Àθí\¹ÙÅÁ È­¸é¡±À̶ó´Â Æú´õ¿¡ ÀúÀåµË´Ï´Ù.

     ' Set shortcut object properties and save it
     With WSHShortcut
          .TargetPath = WSHShell. _
               ExpandEnvironmentStrings(strFullFilePathName)
          .WorkingDirectory = WSHShell. _
               ExpandEnvironmentStrings(strPath)
          .WindowStyle = 4
          .IconLocation = WSHShell. _
               ExpandEnvironmentStrings(Application.Path _
                           & "\excel.exe ,0")
          .Save

À§¿¡¼­ TargetPath, WorkingDirectory, WindowStyle, IconLocation¿Í °°Àº ÇÁ·ÎÆÛƼ´Â ´ÙÀ½ ±×¸²°ú °°ÀÌ [µî·Ï Á¤º¸]´ëÈ­ »óÀÚÀÇ [´ë»óÀ§Ä¡], [½ÃÀÛÀ§Ä¡], [½ÇÇà], [¾ÆÀÌÄÜ º¯°æ] ¹öÆ° Ŭ¸¯½Ã [¾ÆÀÌÄÜ º¯°æ]´ëÈ­ »óÀÚÀÇ [ÆÄÀÏ À̸§] ¿¡ ÇØ´çÇÕ´Ï´Ù.

          End With
          CreateShortcutOnDesktop = 1

     Else
          CreateShortcutOnDesktop = 0
     End If

Continue:
     ' Tidy Up
     Set WSHShell = Nothing
     Exit Function

fCreateShortcutOnDesktop_Err:
     CreateShortcutOnDesktop = -1
     Resume Continue
End Function

Public Sub CreateShortCut()
     If CreateShortcutOnDesktop(ActiveWorkbook.Path & "\" & ActiveWorkbook.Name) = 1 Then
          MsgBox "¹ÙÅÁ È­¸é¿¡ ´ÜÃà ¾ÆÀÌÄÜÀ» ¸¸µé¾ú½À´Ï´Ù.", vbInformation
     Else
          MsgBox "¹ÙÅÁ È­¸é¿¡ ´ÜÃà ¾ÆÀÌÄÜÀ» ¸¸µéÁö ¸øÇß½À´Ï´Ù.", vbInformation
     End If
End Sub
ÇöÀçÀÇ ÅëÇÕ¹®¼­ ¹Ù·Î °¡±â¸¦ ¹ÙÅÁ È­¸é¿¡ ÀúÀåÇÏ´Â ÇÁ·Î½ÃÁ®ÀÔ´Ï´Ù.
¡¡

¿À´ÃÀº ¿©±â±îÁö ÀÔ´Ï´Ù. ´ÙÀ½ ½Ã°£¿¡ ¼ö½Ä°ú °ü·ÃÇÑ ³»¿ëÀ» »ìÆ캸µµ·Ï ÇÏ°Ú½À´Ï´Ù.

¡¡

¸ñÂ÷ | ÀÌÀü | ´ÙÀ½

¡¡

¿ÀÇǽºÆ©ÅÍ ±â¾÷ASP¼­ºñ½º 135-880 ¼­¿ï½Ã °­³²±¸ »ï¼ºµ¿ 157-3 ¿¤ÁöÆ®À©ÅÚ 2Â÷ 1603È£ ¢Ï070-7098-2554
Copyright ¨Ï 1999-2008 Officetutor.com All rights reserved
¡¡