Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

Excel 2000 UNC issue with Visual Basic

  • Please log in to reply




  • Member
  • PipPip
  • 15 posts
I have several Excel 2000 workbooks at work that are shared among several people in our group. All of the workbooks have some Visual Basic coding that points to a location on our share drive or other departments' drives (opening a file, saving a file to certain folder, etc). All of us do not have the same drive letters assigned to these drives, so when we run a macro, we sometimes need to re-map our drives to the correct letter in order for the macro(s) to run properly. I would like to change the portion of the codes that point to a specific letter drive to UNC format. However, when I do this, vb says the path does not exist, I get a run time error '1004', and the macro fails to run. Is it possible that I need to go back and install more options for Excel, or is there something else that could be causing vb not to recognize UNC format? Thanks for any assistance.
  • 0





  • Member
  • PipPip
  • 98 posts
I just did a quick test using the code below;

Sub popeil()
' Macro to count number of files in a directory
' Need to test drive letter assignment vs UNC
Dim myDir As String
Dim myCounter As Integer
'myDir = "Z:\Images\" 'Z: is mapped to \\OPTIMA11\Intray\ Images is a sub directory
myDir = "\\OPTIMA11\Intray\Images\"

With Application.FileSearch
.LookIn = myDir
.Filename = "*.*"
If .Execute > 0 Then
Debug.Print .FoundFiles.Count & " files were found."
End If
End With

End Sub

The code ran successfully and the result was the same for both methods of defining the directory
I am not aware of anything special you need to configure to allow UNC referencing

  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP