Results 1 to 6 of 6
  1. #1
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529

    Error Message -- Path not found.

    Here is my code. Using Office 2007 on this project
    Code:
    Private Sub cmdRunExp_Click()
    'Define Variables
        Dim q1 As String
        Dim thePath As String
        Dim sReg As String
        Dim fileName As String
        Me.Requery
        
     'Check to see if Query has been selected.  If not selected, messagebox and opportunity to try again
        If IsNull(Me.cmbQuery) Or Me.cmbQuery.Value = "" Then
        Beep
        MsgBox "Select Query"
            Exit Sub
        End If
        
     'Set Variables and check to see if a Region has been selected.  If not, the report will indicate Company-Wide vs. Region
        q1 = Me.cmbQuery
        If IsNull(Me.cmbRegion) Then
        sReg = "Company-Wide"
        Else
        sReg = Me.cmbRegion.Column(1)
        End If
        fileName = Me.cmbQuery
        thePath = "G:\FSC\West Southwest\Support\Rebates\2013 P04\Meeting with Alan\Data Output from Access Test\"
        
     'Run Query and Export
        Dim DB As Database
        Dim XLApp, WB As Object
        Set DB = CurrentDb
        
        DoCmd.TransferSpreadsheet acExport, 10, q1, thePath & sReg & fileName
        
        'Open XL file and set Automatic Backup to False
        Set XLApp = CreateObject("Excel.Application")
        Set WB = XLApp.Workbooks.Open(thePath & sReg & fileName)
        XLApp.DisplayAlerts = False
        WB.SaveAs fileName:=thePath & sReg & fileName, CreateBackup:=False
        WB.Close SaveChanges:=True
        XLApp.DisplayAlerts = True
        DB.Close
        Set DB = Nothing
        'Notify User that the file has been exported
        Beep
        Beep
        MsgBox "Your Report for the " & sReg & " Region has been exported"
    
    
    End Sub
    The issue is I am getting an error message on the line highlighted in RED.

    The message reads:

    'G:\FSC\West Southwest\Support\Rebates\2013 P04\Meeting with Alan\Data Output from Access Test\WestRpt-Null Program Names' cannot be found. Check
    your spelling, or try a different path.



    In the code above the string thePath is used to export the file and then attempt to open it. This same code worked for me in another db, so I am a bit at a loss here. The file exports perfectly. The issue is trying to open it and Excel says it cannot be found. Your thoughts on this.

    Thanks

    Alan

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Try putting

    DoEvents

    between the export and that line to make sure the export gets completed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Thanks for the reply Paul. Did not make a difference. This has me really confused as I used same concept last week and it worked just perfectly in another db.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    And the spreadsheet is getting created in the desired folder?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Yes. I just solved it. Simple oversight and then bang! it hit me!
    Added this to the fileName:
    Code:
    fileName = me.cmbQuery & ".xlsx"
    In previous db, had given file name a specific name in the Transferspreadsheet instead of variable. Big Sigh!

    Thanks Paul.

    Alan

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Glad you got it sorted out.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Error Data macro could not be found
    By RoyLittle0 in forum Access
    Replies: 2
    Last Post: 12-26-2012, 10:50 AM
  2. Replies: 7
    Last Post: 06-08-2012, 09:55 PM
  3. Handling Error Message when file path does not exsist
    By brinehart in forum Programming
    Replies: 2
    Last Post: 06-04-2012, 12:33 AM
  4. path /access error 75 is dispalyed
    By PRASANNA in forum Forms
    Replies: 0
    Last Post: 04-27-2011, 04:24 AM
  5. path\file access error 75
    By PRASANNA in forum Programming
    Replies: 2
    Last Post: 04-25-2011, 04:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums