Results 1 to 9 of 9
  1. #1
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53

    save as prompt with hard code path

    I would like to be able to close Excel after queries have run and sheet has been written to. A portion of the code I use to open and write is below. Once the cells have been written I would like the file dialog box to open with a hard coded path that also allows user to change. Any ideas? Second code snippet is one way I have been trying, but not able to get it to work.





    Code:
    Dim objXL As Object
    Dim objWB As Object
    Dim objWS As Object
    Set objXL = CreateObject("Excel.Application")
    Set objWB = objXL.Workbooks.Open("L:\DS\Data Services\Metrics\Dashboard\Dashboard_v1001.xlsx")
    Set objWS = objWB.worksheets("DashBoard")
    Dim db As DAO.Database
    Dim rst As DAO.Recordset
    Dim queryName As String
    
    
        With objWS
        'Cells(row,column)
        .Cells(6, 2).Value = rsCount_Missing_LLC
        .Cells(6, 3).Value = rsCount_Missing_LLC
        
        End With
    Code:
    Dim dlgSaveAs As FileDialog
     Dim strFilePath As String
     Dim strFileName As String
     Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
    
    dlgSaveAs.Show
     strFilePath = dlgSaveAs.SelectedItems("L:\DS\Data Services\Metrics\Dashboard\Dashboard_v1001.xlsx")
     strFileName = Right(strFilePath, Len(strFilePath) - InStrRev(strFilePath, "\"))
     strFilePath = Left(strFilePath, InStrRev(strFilePath, "\"))

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    What does 'not work' mean - error message, wrong results, nothing happens?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53
    Nothing happens

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,913
    The file dialog does not pop up?

    The code you posted looks incomplete.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53
    File dialog opens. It does not seem to be identifying with the excel WB i am writing to.

  6. #6
    DrGUI is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Parts Unknown
    Posts
    23
    Try the InitialFileName property of the dlgSaveAs object

    Set dlgSaveAs = Application.FileDialog(msoFileDialogSaveAs)
    dlgSaveAs.InitialFileName = "L:\DS\Data Services\Metrics\Dashboard\Dashboard_v1001.xlsx"

  7. #7
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53
    Closer with the use on InitialFileName. The File name box on save as prompt is now populated with the correct file name, but when I select save it does not actually save. Any ideas why?

  8. #8
    DrGUI is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Aug 2015
    Location
    Parts Unknown
    Posts
    23
    I don't quite understand why you are using Access to save the file. In this case, you are trying to save an Excel file. Why not save from inside Excel? If appears to me that in order to 'save' something that 'something' must be opened. Otherwise, it doesn't know what it is you are trying to save. Maybe you need to provide more information on what exactly you are trying to accomplish.

  9. #9
    xopherira is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Indiana
    Posts
    53
    Using access to pull in some excel files and query and write to excel files. Would like to be prompted for save once this is finished.

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

Similar Threads

  1. how to hard code a value to a field?
    By eeps24 in forum Access
    Replies: 10
    Last Post: 06-11-2015, 11:00 AM
  2. Replies: 6
    Last Post: 05-27-2014, 05:41 AM
  3. Replies: 5
    Last Post: 08-03-2012, 08:15 AM
  4. Save changes to layout prompt
    By HunterEngineeringCoop in forum Access
    Replies: 2
    Last Post: 07-07-2011, 08:35 AM
  5. Prompt on close and don't save the null record
    By hasanrazaj1 in forum Forms
    Replies: 2
    Last Post: 10-24-2010, 09:24 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