Access VBA to reference a network folder for excel import.

My database imports excel files from a network drive (G:\), but these files have been moved there manually from their location at \\Frxfileserv1\...\.  We now have permission to the source folder, so we should be able to import directly from that location, but the code doesn't like "\\".  How do I reference it correctly?
Jay WilliamsOwnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dale FyeCommented:
can you provide the code that isn't working?
0
Jay WilliamsOwnerAuthor Commented:
Here is the code that is not working:
Public Sub AX01_MASA_REPORT()
    Dim sPath As String, Src1 As String
        sPath = \\Frxfileserv1\FTPDOWN\WW_PUBLIC\Download Folder\New Product Programs-MASA\Local\AX01 & "\"
        Src1 = sPath & "AX01_MASA_REPORT.XLS"
    
    Dim xlObj As Object
    Set xlObj = CreateObject("excel.application")
        xlObj.Workbooks.Open Src1
        xlObj.DisplayAlerts = False
        xlObj.ActiveWorkbook.SaveAs Src1, FileFormat:=51
        xlObj.Quit
        DoCmd.SetWarnings False
        DoCmd.TransferSpreadsheet acImport, 10, "ProcessorT", Src1, True, ""
        xlObj.Quit
       DoCmd.SetWarnings True
    End Sub

Open in new window


As you can see, I'm opening the file and saving it in an import friendly format before import, and it works fine as long as I move the file manually to the current project path:
Public Sub AX01_MASA_REPORT()
    Dim sPath As String, Src1 As String
        sPath = CurrentProject.Path & "\"
        Src1 = sPath & "AX01_MASA_REPORT.XLS"
    
    Dim xlObj As Object
    Set xlObj = CreateObject("excel.application")
        xlObj.Workbooks.Open Src1
        xlObj.DisplayAlerts = False
        xlObj.ActiveWorkbook.SaveAs Src1, FileFormat:=51
        xlObj.Quit
        DoCmd.SetWarnings False
        DoCmd.TransferSpreadsheet acImport, 10, "ProcessorT", Src1, True, ""
        xlObj.Quit
       DoCmd.SetWarnings True
    End Sub

Open in new window

0
Dale FyeCommented:
Ok, so what is it that isn't working?

1.  does xlObj open properly, with the correct file?
2.  you can tell if it opens properly by setting xlObj.Visible = true
3.  do you (or your user) have write permissions to the network path?
4.  between lines 11 and 12 of the first code segment, insert:

set xlObj = nothing

5.  Delete the second line that sets xlObj = Null

6.  If you save the file to the network drive manually, in the appropriate format, can you import the data manually, using the External Data process?

7.  If that works, try running the TransferSpreadsheet method from the immediate window to import that table, also from the network drive.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Jay WilliamsOwnerAuthor Commented:
Good questions and suggestions.  I rather doubt that we have write permissions, but I'll check and see if the file is opening before the error.  I assumed, perhaps incorrectly, that the access was denied before opening; will check it out.  If so, I'll write it to the current project path.

Unclear about the handling of xlObj.  I get setting it to nothing, but I don't see where it is set to null.  What am I missing?
0
Dale FyeCommented:
Jay,

My bad, that should have been

Delete the 2nd line that reads

xlObj.Quit
0
Jay WilliamsOwnerAuthor Commented:
Gotcha.  Working on it now.  Thanks.
0
Jay WilliamsOwnerAuthor Commented:
Back to my original question about referencing the folder; this line turns red in the VBE:
        sPath = \\Frxfileserv1\FTPDOWN\WW_PUBLIC\Download Folder\New Product Programs-MASA\Local\AX01 & "\"
0
Dale FyeCommented:
Don't know how I missed that:

 sPath = "\\Frxfileserv1\FTPDOWN\WW_PUBLIC\Download Folder\New Product Programs-MASA\Local\AX01\"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jay WilliamsOwnerAuthor Commented:
Probably the same way I did. :-)
0
Jay WilliamsOwnerAuthor Commented:
Ok. You answered my question--and more. The file does open, but will not save to the same location, so I'll save it to the current project path, and that should do it.  Problem solved, and thank you!
0
Jay WilliamsOwnerAuthor Commented:
Got a the answer to my question and a sloppy code cleanup suggestion to boot. Thanks Dale.
0
Dale FyeCommented:
glad I could help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.