+ Reply to Thread
Results 1 to 4 of 4

Problem referring to OneDrive folder/files via VBA?

  1. #1
    Registered User
    Join Date
    10-19-2011
    Location
    East Coast
    MS-Off Ver
    Office 365
    Posts
    33

    Problem referring to OneDrive folder/files via VBA?

    Hello - I have been working with the code below to use the .CSV filenames captured on a Worksheet ("RptData_Cleaned") as a 'key' to guide me to a set of .CSV files in a different folder (all in a Microsoft OneDrive environment) to then extract values from the matching file to append to the appropriate row in the "RptData_Cleaned" Worksheet. If I run this code from my 'C:\' drive, it works, if I do it from my OneDrive environment, I only get '#REF!' errors instead of the values I'm targeting. I've tried the Environ ("UserProfile") variable followed by the remainder of the folder path, but that did not help. Any suggestions on how to work around this apparent OneDrive issue?

    Thank you!

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    05-10-2016
    Location
    Cordoba, Argentina
    MS-Off Ver
    2016
    Posts
    27

    Re: Problem referring to OneDrive folder/files via VBA?

    Hi Patdools,
    I did my tests with OneDrive directory and with a non OneDrive directory and I got not differences, your code works well
    But, I was able to get a REF error when:
    The name in the cell includes a wild-char for instance File123.xls* or File123.xls_
    Then the instruction Dir(strPath & cell.Value) work fine because DIR() expects wild-chars and can handle them but
    The statement "='" & strPath & "[" & cell.Value & "]" & strSheet & "'!A14" does not handle wild-chars and you get a REF error
    So I would suggest you to look for wild-chars in the cell containing the file names
    Or debug before assigning .formula I used a dumb variable a3 to debug the REF error to see if the formula is well written
    Please Login or Register  to view this content.
    Cheers
    Sergio

  3. #3
    Registered User
    Join Date
    10-19-2011
    Location
    East Coast
    MS-Off Ver
    Office 365
    Posts
    33

    Re: Problem referring to OneDrive folder/files via VBA?

    Hi Sergio - thank you for the tip on the dummy variable. I did use that code and I see that '.Formula' holds the entire path of the file, the specific (and correct) filename, the Worksheet Name is captured, and the Cell reference ('A14') is also included (but not the actual Value contained in that cell). It all looks correct, yet I'm still ending up with the '#REF' error when running the code. What else can I look at to find out why I can't get the Values I'm targeting in 'A14' & 'B14'?

  4. #4
    Registered User
    Join Date
    05-10-2016
    Location
    Cordoba, Argentina
    MS-Off Ver
    2016
    Posts
    27

    Re: Problem referring to OneDrive folder/files via VBA?

    I guess you will have to debug: debug before assigning .formula I used a dumb variable a3 to debug the REF error to see if the formula is well written
    I added to you code a line to debug the formula before it is assigned to the cell
    Please Login or Register  to view this content.
    Add a break point (F9) on line A3=...
    And see what you get as a formula, copy and assign the value to a cell to see whats happens
    Cheers
    Sergio

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Hyperlink files on OneDrive
    By plans in forum Excel General
    Replies: 0
    Last Post: 05-24-2018, 09:47 PM
  2. Get Share Link from OneDrive files
    By TudyBTH in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-02-2017, 11:49 AM
  3. Replies: 0
    Last Post: 01-15-2017, 06:54 PM
  4. Replies: 0
    Last Post: 09-08-2016, 02:21 PM
  5. Help saving a selection to PDF in a specific OneDrive folder.
    By rcicconetti in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-01-2016, 07:46 AM
  6. Copy an Active Worksheet as a PDF, then have it Uploaded to my OneDrive Folder
    By WesRuss in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-16-2016, 01:47 PM
  7. VBA for files in OneDrive
    By bleeding_me in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2014, 11:21 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1