LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
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 ***
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not copy the file from server to my local C:\ Frank Situmorang Excel Discussion (Misc queries) 3 July 25th 07 12:40 PM
Hyperlinks do not work on local machine. Andrew Links and Linking in Excel 7 June 19th 06 11:11 PM
How to access a database on a server from a local machine using od Todd W Excel Discussion (Misc queries) 0 December 15th 05 03:16 PM
RTD server on remote machine. Mike Kamzyuk Excel Programming 2 January 11th 05 12:23 PM
462 The remote server machine does not exist? Damon[_2_] Excel Programming 1 December 1st 04 12:17 PM


All times are GMT +1. The time now is 10:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"