Results 1 to 9 of 9
  1. #1
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31

    Save As Window

    hello can anyone provide me some further information on the code contained in the following link?

    http://access.mvps.org/access/api/api0001.htm

    i am trying to click a button and it opens the save as window and then stores the location path as a variable.



    but i have limited knowledge in programming, so if someone could explain where i should place that code and how to call it from a form would be muchly appreciated

    thanks in advance

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    you don't need an api to do this. The following will work fine, using the mso:

    Code:
    function PickAFolder() as string
          Dim varItem As Variant
           
          With Application.FileDialog(msoFileDialogFolderPicker)
                 .AllowMultiSelect = False
                 .InitialFileName = "c:"
                 .InitialView = msoFileDialogViewDetails
                        If .Show Then
                            PickAFolder = varItem
                        End If
          End With
    end function
    if all you want to do is have the user pick a file, the above does just that. I think you also need a reference to "ms office xx.0 library" though.

  3. #3
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31
    Ok thank you!! nothing was working because i didn't have the correct imports. Does anyone know what i would have to add to assign the selected file path from that code to a string variable so i can output the file path selected in a message box?

    thanks

  4. #4
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31
    so using the function above, you cant assign the file path selected to a string?? ;/

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Quote Originally Posted by Coffee View Post
    so using the function above, you cant assign the file path selected to a string?? ;/
    You would use something like this:
    Code:
    Dim strFile As String
     
    strFile = PickAFolder

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by boblarson View Post
    You would use something like this:
    Code:
    Dim strFile As String
     
    strFile = PickAFolder
    I thought we would've figured that part out. Didn't see a need to include it!

    But then again, ya never know!

  7. #7
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31
    i done that, but then when i say

    MsgBox strFile

    it returns a blank message window and shouldn't it return the message window with the path string?

  8. #8
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by Coffee View Post
    i done that, but then when i say

    MsgBox strFile

    it returns a blank message window and shouldn't it return the message window with the path string?
    it might be cutting it off if it's too long a string? If you push cancel, you won't get anything I dont think.

    if you double click the file or hit OK, it should return the string.

  9. #9
    Coffee is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Jul 2011
    Location
    Australia
    Posts
    31
    ah i just tried it in my main code instead of the test form and even though it doesn't output the path in a message box it still outputs it somewhere and is working :P i feel like a giant noob wasting so much time on this where as if i just put it in the code regardless it would have worked...oh well live and learn!!

    i changed it to a FileDialogSaveAs so that the user would be able to supply their own file name, but this way doesn't work and keeps saying that the file already exist when it clearly doesn't ;/

    thanks guys for your help and baring with me! much appreciated xD

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

Similar Threads

  1. how to pop up query window?
    By Nokia N93 in forum Forms
    Replies: 2
    Last Post: 03-28-2011, 01:11 AM
  2. Replies: 9
    Last Post: 01-20-2011, 02:22 PM
  3. get window nfo
    By alcoool in forum Access
    Replies: 3
    Last Post: 01-18-2010, 09:58 AM
  4. Default window
    By Tareq_1993 in forum Access
    Replies: 2
    Last Post: 11-26-2009, 09:37 AM
  5. Access Window On top
    By Jas_The_Ace in forum Programming
    Replies: 0
    Last Post: 02-28-2009, 04:28 PM

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