Welkom op het forum van startpagina!

Dit forum staat op alleen-lezen. Je kan hier informatie zoeken en oude berichten terugvinden, maar geen nieuwe berichten plaatsen.

Naar overzicht van alle forums

variabel pad gebruiken met Mfilename VBA

  • Andre Bruin

    Goedemiddag,

    ik heb een rapport die automatisch als pdf wordt opgeslagen in een bepaalde map die ik in de code heb gezet.

    Dat gaat allemaal goed, maar nu wil ik dat het pad niet hard in deze code staat, maar dat ik dat in een tabel zet, zodat ik het pad aan de voorkant van het programma kan veranderen als ik de files in een andere map wil opslaan. Op één of andere manier lukt met het niet om het variabel te krijgen, enig idee hoe ik dit moet doen?

    zie code hieronder:

    Dim vl_Criteria As Variant

    Dim sRep As String

    Dim stReport As String

    Dim stWhere As String

    Dim mFilename As String

    vl_Criteria = Me.Debiteur_nr

    mFilename = “C:\Users\andre\Desktop\test_map_NFO\” & Me.bedrijf & “.pdf”

    stReport = “Uitnodiging voor standhouders”

    If Me.Selecteer = True Then

    DoCmd.OutputTo acOutputReport, stReport, acFormatPDF, mFilename

    alvast bedankt.

    André

  • wimmie

    Option Compare Database

    Public Type BROWSEINFO

    hOwner As Long

    pidlRoot As Long

    pszDisplayName As String

    lpszTitle As String

    ulFlags As Long

    lpfn As Long

    lParam As Long

    iImage As Long

    End Type

    '32-bit API declarations

    Declare Function SHGetPathFromIDList Lib “shell32.dll” _

    Alias “SHGetPathFromIDListA” (ByVal pidl As Long, ByVal pszPath As String) _

    As Long

    Declare Function SHBrowseForFolder Lib “shell32.dll” _

    Alias “SHBrowseForFolderA” (lpBrowseInfo As BROWSEINFO) As Long

    Sub test()

    Dim msg As String

    msg = “Please select a location for the backup.”

    MsgBox GetDirectory(msg)

    End Sub

    Function GetDirectory(Optional msg) As String

    Dim bInfo As BROWSEINFO

    Dim path As String

    Dim r As Long, x As Long, pos As Integer

    ' Root folder = Desktop

    bInfo.pidlRoot = 0&

    ' Title in the dialog

    If IsMissing(msg) Then

    bInfo.lpszTitle = “Select a folder.”

    Else

    bInfo.lpszTitle = msg

    End If

    ' Type of directory to return

    bInfo.ulFlags = &H1

    ' Display the dialog

    x = SHBrowseForFolder(bInfo)

    ' Parse the result

    path = Space$(512)

    r = SHGetPathFromIDList(ByVal x, ByVal path)

    If r Then

    pos = InStr(path, Chr$(0))

    GetDirectory = Left(path, pos - 1)

    Else

    GetDirectory = “”

    End If

    End Function