Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Excel 2000 UNC issue with Visual Basic


  • Please log in to reply

#1
popeil

popeil

    Member

  • 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

Advertisements


#2
dsm

dsm

    Member

  • Member
  • PipPip
  • 98 posts
popeil,
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

regards
dsm
  • 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