希望这有帮助
您只需要一个表单来输入“jobno”和目录字母(newdatadrive)
- Private Sub commandbutton1_Click()
- Dim newdatadrive As String
- Dim jobno As String
- Dim MyPath, MyName, checkfile
- Dim SourceFile, DestinationFile As String
- Dim civ3dfile As String
- jobno = projectno.Value
- newdatadrive = datadrive.Value + ":"
- coggfilecopy1.Hide
- 'check to see if current drawing
- currentdwgname = ThisDrawing.GetVariable("Dwgname") 'noofchar = Len(currentdwgname)
- currentdwgname = Mid$(currentdwgname, 1, 7) 'only need 1st 7 characters
- 'MsgBox "dwg name" & currentdwgname
- If currentdwgname = jobno Then
- MsgBox "You can not save the drawing if you have it open" & (Chr(13)) & "Please close and try again"
- GoTo COGGEND
- End If
- checkfile = "P:" + jobno + "\Design" + jobno + "-data"
- 'How to determine if a file exists in a folder:
- If Dir(checkfile, vbDirectory) = "" Then
- 'makenewdir
- MsgBox "Directory does not exist now making"
- MkDir "P:" + jobno + "\Design" + jobno + "-data"
- MkDir "P:" + jobno + "\Design" + jobno + "-data\Advroads"
- Else
- MsgBox "Directory found now continue" & checkfile
- End If
- ' Define source file name D:\Civil 3D Projects\jobno\jobno.dwg.
- SourceFile = newdatadrive + "\Civil 3D Projects" + jobno + "" + jobno + ".dwg"
- ' Define target file name.
- DestinationFile = "P:" + jobno + "\design" + jobno + ".dwg"
- 'copy file
- MsgBox "file copied " & DestinationFile
- FileCopy SourceFile, DestinationFile
- ' Display the names in C:\ that represent directories.
- MyPath = newdatadrive + "\Civil 3D Projects" + jobno + "" + jobno + "-data\Advroads" ' Set the path.
- 'myname = Dir(Mypath, vbDirectory) '1st entry
- MyName = Dir(MyPath) '2nd entry 1st is .. not needed
- Do While MyName <> "" ' Start the loop.
- SourceFile = newdatadrive + "\Civil 3D Projects" + jobno + "" + jobno + "-data\Advroads" + MyName ' Define source file name D:\Civil 3D Projects\2006100\2006100.dwg.
- DestinationFile = "P:" + jobno + "\design" + jobno + "-data\Advroads" + MyName ' Define source file name D:\Civil 3D Projects\2006100\2006100.dwg.
- FileCopy SourceFile, DestinationFile
- MsgBox "file copied " & MyName
- MyName = Dir ' Get next entry.
- Loop 'end of loop
- GoTo COGGEND
- notright:
- MsgBox "enter a job no or data drive"
- frmcoggfilecopy1.Show
- COGGEND:
- End Sub
|