+ Reply to Thread
Results 1 to 10 of 10

Open Text File For Output On OneDrive

Hybrid View

OzTrekker Open Text File For Output On... 08-25-2023, 04:11 AM
Marc L Re: Open Text File For Output... 08-25-2023, 04:49 AM
OzTrekker Re: Open Text File For Output... 08-25-2023, 05:00 AM
Marc L Re: Open Text File For Output... 08-25-2023, 05:20 AM
AliGW Re: Open Text File For Output... 08-25-2023, 05:21 AM
Marc L Re: Open Text File For Output... 08-25-2023, 05:40 AM
OzTrekker Re: Open Text File For Output... 08-25-2023, 07:51 AM
AliGW Re: Open Text File For Output... 08-25-2023, 07:55 AM
OzTrekker Re: Open Text File For Output... 08-25-2023, 07:00 PM
Marc L Re: Open Text File For Output... 08-25-2023, 07:27 PM
  1. #1
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Open Text File For Output On OneDrive

    Hi Folks,

    I have some code that I use to output to a text file.
    It works fine if the file it is located in is stored on a local drive.
    However, if the file is stored on OneDrive it generates a "Bad file name or number" error.
    Can I adapt this code to work when the file is located on OneDrive?
    The file is used by numerous people so it needs to handle the OneDrive path dynamically.

    Open ActiveWorkbook.Path & "/" + strOutputFileName For Output As f
    Select "Add Reputation" to thank me.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Open Text File For Output On OneDrive


    Hi,

    maybe if you just ask to your IT what is the static synchronized local path for your 'OneDrive numerous people' …

  3. #3
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Re: Open Text File For Output On OneDrive

    Hi Marc L,

    I can't do that.
    The file is used by random members of a sporting organisation.
    The path is not static.

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Open Text File For Output On OneDrive


    You misread / misunderstood, just see with your IT then you should understand. Like in threads within this forum about the same subject …

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,201

    Re: Open Text File For Output On OneDrive

    Do I understand correctly that this is a file being shared via one of the members' personal OneDrive?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Open Text File For Output On OneDrive


    Another obvious way is to first create the text file to a local drive path then copy the file to OneDrive if really necessary …

  7. #7
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Re: Open Text File For Output On OneDrive

    Hi AliGW,

    No, that's not correct.
    The file is being distributed to various members of a sporting organisation.
    They populate the original file and then generate the *.TXT file which is used in a downstream process.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,201

    Re: Open Text File For Output On OneDrive

    The file is being distributed to various members of a sporting organisation.
    How?

    They populate the original file
    How? If the file is being 'distributed' to them, then they must be working on a copy. If not, what do you mean by 'distribute'?

    then generate the *.TXT file which is used in a downstream process.
    What TXT file?

    I think you need to be more detailed about your set-up.

  9. #9
    Forum Contributor
    Join Date
    06-18-2007
    Location
    Kiama, Australia
    MS-Off Ver
    365
    Posts
    119

    Re: Open Text File For Output On OneDrive

    Sorry if I have not been clear enough.

    The file is being distributed to members of a sporting organisation via email.
    They store a copy locally and populate it.
    Once the file is fully populated they run a VBA procedure, via a button in the worksheet, that creates a .TXT file.
    The.TXT file is located in the same Folder as the parent Excel workbook.
    The .TXT file is then forwarded, via email, to the event Administrator.
    The Administrator imports the contents into a database.

    The issue I have struck is creating the .TXT file.
    If the original, populated Excel file is saved on a local drive my code works fine.
    If it is located on OneDrive it generates a "Bad file name or number" error.

    The following code creates the "Output.txt" file.
    Can it be adapted to create this .TXT file irrespective of where the parent Excel workbook is located?
    I can test the location of the parent file and act accordingly.

    Open ActiveWorkbook.Path & "/Output.txt" For Output As f

  10. #10
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: Open Text File For Output On OneDrive


    Just update the folder path to the local OneDrive path or any other local path …

+ 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. Replies: 0
    Last Post: 12-21-2021, 07:25 AM
  2. [SOLVED] Saving a file to onedrive shared network and access via onedrive online
    By Sintek in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 03-09-2021, 11:56 AM
  3. Open File for Output to xlsx
    By foxtrotter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-18-2020, 10:08 PM
  4. Migrating to Windows 7 - Open file for output unreliable
    By mgs73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-17-2014, 08:57 PM
  5. Open a print output sent to file
    By Ted Johnston in forum Excel General
    Replies: 0
    Last Post: 02-24-2006, 06:15 AM
  6. [SOLVED] Open CSV file, format data and write output to a text file.
    By BristolBloos in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2005, 11:05 AM
  7. Cannot open file for output
    By DavidTM in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-27-2005, 05:05 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