Results 1 to 5 of 5
  1. #1
    Lesg is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Sep 2021
    Posts
    101

    Save PDF using windows variables

    Hi Guys,



    I am trying to save a file to a onedrive location in a multi user environment, all users have a folder, invoices, that is a sharepoint folder added to file explorer.

    My Code is:

    Code:
    StrFileName = Me.CustName & "_" & "invoice" & "_" & Me.invoice & ".pdf"
    StrFileName = "%OneDrive%\Invoices\" & StrFileName
    I had thought that the windows variable %OneDrive% would add that part of the path, but rather than:

    {C:}\{Users}\{user}\{OneDrive}\Invoices\filename.p df

    I am getting:

    %OneDrive%\Invoices\customer_invoice_65609.pdf

    Thanks in advance

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    You would likely need Environ("OneDrive") if it exists?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    Lesg is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Sep 2021
    Posts
    101
    Quote Originally Posted by Welshgasman View Post
    You would likely need Environ("OneDrive") if it exists?
    Can you clarify what you mean please, All users have OneDrive

  4. #4
    Lesg is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Sep 2021
    Posts
    101
    Quote Originally Posted by Lesg View Post
    Can you clarify what you mean please, All users have OneDrive
    Its ok, I have done a search for ENVIRON and see now what you mean and got it working fine now:



    Code:
    Code:
    Dim StrPath As String
    Dim StrFileName As String
    Dim strReport As String
    
    strReport = "rptInvoice_Dispatch_edit"
    StrPath = Environ$("OneDrive")
    
    StrFileName = Me.CustName & "_" & "invoice" & "_" & Me.invoice & ".pdf"
    StrFileName = StrPath & "\Invoices_SP\" & StrFileName
    Many thanks again

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,861
    Quote Originally Posted by Lesg View Post
    Can you clarify what you mean please, All users have OneDrive
    I would prefer to check all the same?
    If for some strange reason that system variable is not present then use another path and inform user? That way no need to fix anything if that happens.?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. Replies: 2
    Last Post: 04-20-2020, 04:01 PM
  2. Replies: 10
    Last Post: 04-07-2020, 05:40 PM
  3. Replies: 1
    Last Post: 05-30-2019, 06:15 AM
  4. Replies: 1
    Last Post: 05-11-2018, 10:11 AM
  5. Replies: 5
    Last Post: 06-29-2015, 11:30 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