View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Myrna Rodriguez[_2_] Myrna Rodriguez[_2_] is offline
external usenet poster
 
Posts: 4
Default Move Folders on the Server vs. Local Machine

Hi VB debuggers,

Is there a difference when moving folders on the server and local
machine (server = S:/ local = C:/)??

PROGRAM MISSION:
I have programmed code in Excel VBA to move folders when the user
selects an item in a combo box. Once the user saves the change, the
folder should move to it corresponding path.

PROBLEM:
The code fails when running the program on the server S:/
I get an error message box "Specified path not found"

Where did I go wrong? Thanks in advance for you help and continue to
enjoy life... Myrna Rodriguez


THIS IS THE CODE:
Private Sub cmdots_Click()
'Show OTS Form
UserForm1.Show
End Sub

Private Sub CommandButton1_Click()

Call RegenerateLinks

End Sub


Sub RegenerateLinks()
'Declarations
Dim Nextrow As Long
Dim myRange As Range
Dim x As String
Dim cell As Range
Dim fastNumValue As String
Dim fileLocation As String
Dim link As String
Dim rowCount As Integer
Dim h As Hyperlink
Dim newAddress As String
Dim debugThis As Boolean
Dim newfolder As String

debugThis = False

rowCount = 0

Set myRange = Range("A3").CurrentRegion

For Each rw In Worksheets(1).Cells(1, 1).CurrentRegion.Rows

rowCount = rowCount + 1

fastNumValue = rw.Cells(1, 1).Value
If debugThis Then MsgBox "fastNumValue : " & fastNumValue

fileLocation = rw.Cells(1, 16).Value
If debugThis Then MsgBox "fileLocation : " & fileLocation


For Each h In rw.Hyperlinks

'MsgBox ActiveWorkbook.FullName

link = h.Name
If debugThis Then MsgBox "link h.name : " & link

If InStr(fileLocation, "Open") < 0 Then

If InStr(h.Name, "Open") < 0 Then

If debugThis Then MsgBox "is ok"

ElseIf InStr(h.Name, "Post-Close") < 0 Then

If debugThis Then MsgBox "not ok"

newAddress = Replace(h.Address, "Post-Close", "Open")

If debugThis Then MsgBox "newAddress : " & newAddress

'moving the files now
oldFullAddress = HyperLinkTextH(h)
If debugThis Then MsgBox "oldFullAddress : " &
oldFullAddress

newFullAddress = Replace(oldFullAddress, "Post-Close",
"Open")
If debugThis Then MsgBox "newFullAddress : " &
newFullAddress

Set fso = CreateObject("Scripting.FileSystemObject")
'check if file exists first
If fso.folderexists(oldFullAddress) Then

Set mainfolder = fso.GetFolder(oldFullAddress)
mainfolder.Move newFullAddress

End If

h.Address = newAddress

If debugThis Then MsgBox "newAddress added : " &
h.Address

ElseIf InStr(h.Name, "Archived") < 0 Then

If debugThis Then MsgBox "not ok"
newAddress = Replace(h.Address, "Archived", "Open")

If debugThis Then MsgBox "newAddress : " & newAddress

'moving the files now
oldFullAddress = HyperLinkTextH(h)
If debugThis Then MsgBox "oldFullAddress : " &
oldFullAddress

newFullAddress = Replace(oldFullAddress, "Archived",
"Open")
If debugThis Then MsgBox "newFullAddress : " &
newFullAddress

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(oldFullAddress) Then

Set mainfolder = fso.GetFolder(oldFullAddress)
mainfolder.Move newFullAddress

End If

h.Address = newAddress

If debugThis Then MsgBox "newAddress added : " &
h.Address

End If

End If

If InStr(fileLocation, "Post-Close") < 0 Then

If InStr(h.Name, "Open") < 0 Then

If debugThis Then MsgBox "not ok"
newAddress = Replace(h.Address, "Open", "Post-Close")

If debugThis Then MsgBox "newAddress : " & newAddress

'moving the files now
oldFullAddress = HyperLinkTextH(h)
If debugThis Then MsgBox "oldFullAddress : " &
oldFullAddress

newFullAddress = Replace(oldFullAddress, "Open",
"Post-Close")
If debugThis Then MsgBox "newFullAddress : " &
newFullAddress

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(oldFullAddress) Then

Set mainfolder = fso.GetFolder(oldFullAddress)
mainfolder.Move newFullAddress

End If

h.Address = newAddress

If debugThis Then MsgBox "newAddress added : " &
h.Address

ElseIf InStr(h.Name, "Post-Close") < 0 Then

If debugThis Then MsgBox "is ok"

ElseIf InStr(h.Name, "Archived") < 0 Then

If debugThis Then MsgBox "not ok"

newAddress = Replace(h.Address, "Archived",
"Post-Close")

If debugThis Then MsgBox "newAddress : " & newAddress

'moving the files now
oldFullAddress = HyperLinkTextH(h)
If debugThis Then MsgBox "oldFullAddress : " &
oldFullAddress

newFullAddress = Replace(oldFullAddress, "Archived",
"Post-Close")
If debugThis Then MsgBox "newFullAddress : " &
newFullAddress

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(oldFullAddress) Then

Set mainfolder = fso.GetFolder(oldFullAddress)
mainfolder.Move newFullAddress

End If
h.Address = newAddress

If debugThis Then MsgBox "newAddress added : " &
h.Address

End If

End If

If InStr(fileLocation, "Archived") < 0 Then

If InStr(h.Name, "Open") < 0 Then

If debugThis Then MsgBox "not ok"

newAddress = Replace(h.Address, "Open", "Archived")

If debugThis Then MsgBox "newAddress : " & newAddress

h.Address = newAddress

'moving the files now
oldFullAddress = HyperLinkTextH(h)
If debugThis Then MsgBox "oldFullAddress : " &
oldFullAddress

newFullAddress = Replace(oldFullAddress, "Open",
"Archived")
If debugThis Then MsgBox "newFullAddress : " &
newFullAddress

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(oldFullAddress) Then

Set mainfolder = fso.GetFolder(oldFullAddress)
mainfolder.Move newFullAddress

End If

If debugThis Then MsgBox "newAddress added : " &
h.Address

ElseIf InStr(h.Name, "Post-Close") < 0 Then

If debugThis Then MsgBox "not ok"
newAddress = Replace(h.Address, "Post-Close",
"Archived")

If debugThis Then MsgBox "newAddress : " & newAddress

'moving the
files now
oldFullAddress = HyperLinkTextH(h)
If debugThis Then MsgBox "oldFullAddress : " & oldFullAddress

newFullAddress = Replace(oldFullAddress, "Post-Close", "Archived")
If debugThis Then MsgBox "newFullAddress : " &
newFullAddress

Set fso = CreateObject("Scripting.FileSystemObject")
If fso.folderexists(oldFullAddress) Then

Set mainfolder = fso.GetFolder(oldFullAddress)
mainfolder.Move newFullAddress

End If

h.Address = newAddress

If debugThis Then MsgBox "newAddress added : " &
h.Address

ElseIf InStr(h.Name, "Archived") < 0 Then

If debugThis Then MsgBox "is ok"

End If

End If

Next

Next

If debugThis Then MsgBox rowCount

End Sub

*** Sent via Developersdex http://www.developersdex.com ***