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

[µo°Ý] ¤G¥x¹q¸£¤§¶¡Àɮ׽ƻs¦³®É¤£¦æ©O¡H

[µo°Ý] ¤G¥x¹q¸£¤§¶¡Àɮ׽ƻs¦³®É¤£¦æ©O¡H

¥»©«³Ì«á¥Ñ dechiuan999 ©ó 2014-8-21 16:41 ½s¿è

¦U¦ì¤j¤j¦n¡G
TEST.rar (22.9 KB)
¤p§Ì·Q§Q¥Înet«ü¥O¨Ó

¥»©«³Ì«á¥Ñ dechiuan999 ©ó 2014-8-21 18:31 ½s¿è

TEST.rar (21.79 KB)
  1. Sub mXcopy()   
  2.     Dim Wsh As IWshRuntimeLibrary.WshShell  '¦¹«Å§i¬O§_¦³»~©O¡H
  3.     Dim sourceFile As String
  4.     Dim destinationFile As String
  5.     Dim fs As Scripting.FileSystemObject    '¦¹«Å§i¬O§_¦³»~©O¡H
  6.     Dim cmdStr
  7.     Dim retVal
  8.     Set Wsh = CreateObject("WScript.Shell")
  9.         Wsh.Run "cmd /c net use O: \\multibay\SCAN"        
  10.         
  11.         sourceFile = "O:\" & mTb.Text & ".PDF"
  12.         destinationFile = "D:\TEMP\."
  13.         Set fs = CreateObject("scripting.filesystemobject")
  14.         If fs.FileExists(sourceFile) Then
  15.             cmdStr = "cmd /c copy " & sourceFile & " " & destinationFile
  16.             retVal = Shell(cmdStr, 0)
  17.         Else
  18.             MsgBox "¿é¤Jªº¤¤¤å¼ÐÅÒÀɮצWºÙ¤£¦s¦b" & vbCrLf & "½Ð­«·s¿é¤J«ü©wªº¤¤¤å¼ÐÅÒ"
  19.         End If
  20.         
  21.         Wsh.Run "cmd /c net use O: /delete"
  22.         
  23.         Set fs = Nothing
  24.         Set Wsh = Nothing
  25.       
  26. End Sub
½Æ»s¥N½X
¦^´_ 1# dechiuan999

¸É¥R»¡©ú ¦pªþÀÉ

TOP

¦^´_ 2# dechiuan999
1. ©w¸q¦b Sub °Ï¶ô¤ºªºÅܼƥu¯à¦b¸Ó°Ï¶ô¤º¨Ï¥Î, (¨ä¥Lªº Sub ¤º¬Ý¤£¨ì¸ÓÅܼÆ)
­Y¨C­Ó Sub ³£»Ý­n¥Î¨ì(©Î¬O»Ý­n¦b Sub ¶¡¶Ç»¼)ªºÅܼÆ,
½Ð¦b Module ¤ºªº Option Explicit ¤W¤è,
¨Ï¥Î Public ¨ú¥N Dim ©w¸q¥þ°ìÅܼÆ.
¦p:
Public Wsh As Object. fs As Object
Option Explicit
Sub nn()
...
End Sub

2.
    Dim Wsh As Object
...
    Dim fs As Object
§ï©w¸q¦¨ Object ¸Õ¸Õ.

TOP

¦^´_ 3# luhpro


    ÁÂÁ¤j¤jªº´£¥Ü
¤p§Ì©ú¤é¦^¤½¥q«á¦A¸Õ¸Õ

·P®¦¤j¤j¡I

TOP

¦^´_ 3# luhpro


    ÁÂÁ¤j¤j¡C
¤p§Ì¤µ¤é¦b¤½¥q
¨Ì¤j¤jªº¤è¦¡¡A¨ä
µ²ªGÁÙ¬O¬Û¦P¡C
²{¤p§Ì§ï¥Î¤U¦C¤è¦¡
¹B§@
  1. '³]©w¤Þ¥Î¶µ¥Ø Windows Script Host Object Model
  2.    
  3.     Dim myWsh As IWshRuntimeLibrary.WshShell
  4.     Dim myStr As String
  5.     Dim myFso     As Scripting.FileSystemObject
  6.     Dim myName    As String
  7.     Dim myNewPath As String
  8.    
  9.    
  10.     Set myWsh = CreateObject("Wscript.Shell")
  11.     myStr = "\\multibay\scan"               '«ü©w¸ê®Æ§¨
  12.     'Debug.Print CurDir
  13.     myWsh.CurrentDirectory = myStr
  14.     'Debug.Print CurDir
  15.    
  16.     Set myFso = New Scripting.FileSystemObject
  17.     myName = "\\multibay\scan\T-1.PDF"      '½Æ»s¨Ó·½ÀÉ®×
  18.     myNewPath = "D:\TEMP\"        '«ü©w½Æ»s¥Ø¼Ð
  19.     myFso.CopyFile myName, myNewPath, OverWriteFiles:=True
  20.     '¤£¯à¨Ï¥ÎMask¦r¤¸
  21.     'myFso.GetFile(myName).Copy myNewPath, OverWriteFiles:=True
  22.     Set myFso = Nothing                            'ª«¥óªºÄÀ©ñ
  23.     Set myWsh = Nothing                            'ª«¥óªºÄÀ©ñ
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¨C¤ÑµL©Ò¨Æ¨Æ¡A¬O¤H¥Íªº®ø¶OªÌ¡A¿n·¥¡B¦³¥Î¤~¬O¤H¥Íªº³Ð³yªÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD