Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 *** |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can not copy the file from server to my local C:\ | Excel Discussion (Misc queries) | |||
Hyperlinks do not work on local machine. | Links and Linking in Excel | |||
How to access a database on a server from a local machine using od | Excel Discussion (Misc queries) | |||
RTD server on remote machine. | Excel Programming | |||
462 The remote server machine does not exist? | Excel Programming |