Message 1 of 4
Code Problem?
Not applicable
01-05-2000
08:08 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Could someone please act as another set of eyes for me? The following
code works fine if there is a preexistent path, but if the code has to
write the path to the drive, it creates all the directories except the
last one. I can't seem to pin down the problem.
thanks in advance,
-Josh
Option Explicit
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal
lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
bFailIfExists As Long) As Long
Public MyPath As String
Public MyName As String
Dim NewDir As String
Dim AlternatePath As String
Dim AlternatePathName As String
Public Sub test_Sav2Floppy()
Dim StringCount As Integer
Dim MidPath As String
Dim CopyCount As Integer
Dim testSlash As String
Dim DirectoryInfo As String
If Len(ThisDrawing.Name) > 7 Then
If Mid$(ThisDrawing.Name, 1, 7) = "Drawing" Then
MsgBox "You Must First Save the Drawing to a Name Using the
Saveas Command Before You Can Use Save to Floppy.", vbCritical
End
End If
End If
If Mid$(ThisDrawing.FullName, 1, 12) = "S:\DWG\Jobs\" Then
StringCount = Len(ThisDrawing.FullName) - 12
AlternatePathName = "A" & ":\" & Mid$(ThisDrawing.FullName, 13,
StringCount)
StringCount = Len(ThisDrawing.Path) - 12
AlternatePath = "A" & ":\" & Mid$(ThisDrawing.Path, 13, StringCount)
& "\"
Else
StringCount = Len(ThisDrawing.FullName) - 1
AlternatePathName = "A" & Mid$(ThisDrawing.FullName, 2, StringCount)
StringCount = Len(ThisDrawing.Path) - 1
AlternatePath = "A" & Mid$(ThisDrawing.Path, 2, StringCount) & "\"
End If
ThisDrawing.Save
If Dir(AlternatePath) = "" Then
NewDir = "A:\"
DirectoryInfo = AlternatePath
CopyCount = 4
Do While CopyCount < Len(DirectoryInfo)
testSlash = Mid$(DirectoryInfo, CopyCount, 1)
If testSlash <> "\" Then
NewDir = NewDir & testSlash
ElseIf testSlash = "\" Then
If Dir(NewDir, vbDirectory) = "" Then MkDir NewDir
NewDir = NewDir & testSlash
End If
CopyCount = CopyCount + 1
Loop
SaveDwg AlternatePathName
End If
End Sub
code works fine if there is a preexistent path, but if the code has to
write the path to the drive, it creates all the directories except the
last one. I can't seem to pin down the problem.
thanks in advance,
-Josh
Option Explicit
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal
lpExistingFileName As String, ByVal lpNewFileName As String, ByVal
bFailIfExists As Long) As Long
Public MyPath As String
Public MyName As String
Dim NewDir As String
Dim AlternatePath As String
Dim AlternatePathName As String
Public Sub test_Sav2Floppy()
Dim StringCount As Integer
Dim MidPath As String
Dim CopyCount As Integer
Dim testSlash As String
Dim DirectoryInfo As String
If Len(ThisDrawing.Name) > 7 Then
If Mid$(ThisDrawing.Name, 1, 7) = "Drawing" Then
MsgBox "You Must First Save the Drawing to a Name Using the
Saveas Command Before You Can Use Save to Floppy.", vbCritical
End
End If
End If
If Mid$(ThisDrawing.FullName, 1, 12) = "S:\DWG\Jobs\" Then
StringCount = Len(ThisDrawing.FullName) - 12
AlternatePathName = "A" & ":\" & Mid$(ThisDrawing.FullName, 13,
StringCount)
StringCount = Len(ThisDrawing.Path) - 12
AlternatePath = "A" & ":\" & Mid$(ThisDrawing.Path, 13, StringCount)
& "\"
Else
StringCount = Len(ThisDrawing.FullName) - 1
AlternatePathName = "A" & Mid$(ThisDrawing.FullName, 2, StringCount)
StringCount = Len(ThisDrawing.Path) - 1
AlternatePath = "A" & Mid$(ThisDrawing.Path, 2, StringCount) & "\"
End If
ThisDrawing.Save
If Dir(AlternatePath) = "" Then
NewDir = "A:\"
DirectoryInfo = AlternatePath
CopyCount = 4
Do While CopyCount < Len(DirectoryInfo)
testSlash = Mid$(DirectoryInfo, CopyCount, 1)
If testSlash <> "\" Then
NewDir = NewDir & testSlash
ElseIf testSlash = "\" Then
If Dir(NewDir, vbDirectory) = "" Then MkDir NewDir
NewDir = NewDir & testSlash
End If
CopyCount = CopyCount + 1
Loop
SaveDwg AlternatePathName
End If
End Sub