+ Reply to Thread
Results 1 to 18 of 18

Access to C: drive

  1. #1
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Unhappy Access to C: drive

    The following code works fine but when I "ChDir "C:\" I get a file/path error

    Please Login or Register  to view this content.
    I declared C drive as a trusted source with no results.
    How can I negotiate files directly to C drive?
    Turn Data into Information
    Turn Information into Knowledge
    Turn Knowledge into Direction
    Turn Direction into Leadership
    Turn Leadership into Results
    Stephen Druley

    It's not how quickly you think
    But how deeply you think
    The quality of thinking is measured
    by remoteness to conformance
    Stephen Druley

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,658

    Re: Access to C: drive

    Not sure you can these days ... but it's a Windows issue rather than an Excel problem (I think).

    I have Windows 7 and find that I can't create files in the root of the C: drive. I suspect this is to prevent corruption and to minimise the impact of viruses, etc.

    I've settled for having a sub-folder on the C: drive which I can access and create and delete files. If, in Windows Explorer, I open the C: drive and right click, the only option I get is to create a folder, nothing else. Equally, if I create a .txt file with Notepad and try to save it to the C: drive I get a message to the effect that I do not have permission and to contact the Administrator. If I run Notepad as Administrator, I can save my file to the C: drive.

    Hope this helps

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Access to C: drive

    You shouldn't use chdir in VBA.
    because it's not clear what is in 'Efile'
    in your case it could be

    Please Login or Register  to view this content.



  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,658

    Re: Access to C: drive

    @snb: I suspect the issue is not whether or not to use ChDir, but the fact that you need to be in Admin mode to write to the C: drive, full stop.

    Might be a registry hack to get round it but that would probably put the system at risk.

    Regards, TMS

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: Access to C: drive

    It will depend on where on the C drive you are writing, but as snb said, ChDir is rarely necessary. if you do use it, you should always use ChDrive first anyway.
    Remember what the dormouse said
    Feed your head

  6. #6
    Valued Forum Contributor
    Join Date
    07-21-2008
    Location
    London, UK
    Posts
    326

    Re: Access to C: drive

    Is this for work or home use - if you ADMIN should be basic code, the change DIR stuff is and CMD window you can just line code the target in VBA as has been expressed already (not picking just stating)

    if work speak with IT in case some funky stuff going on - and remember C might not be C HDD if your profiled out could be more or less anything

    Can you see the C root on Windows Explorer, if co can you manually test / open the file?
    Xp will be fine and if you can the code will work, if not, you got a problem

    See what you come back with and maybe a MOD will move this to Windows forum not sure your version

    Se7en Pro (x64) and Ultimate (x68) are OK to write to the but not the C root you can add a folder and dump the files in there, but not add direct to the boot partition, Xp however You can - i assume X86 flavours are the same as X86

  7. #7
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Question Re: Access to C: drive

    Thank you gentlemen,

    I have followed the snb recommended format and have ridded the program of chdir syntax.
    We are still getting run time error 75 stating "Path/File Access error".

    I am using Excel 2010 64bit in Windows 7 and I am the administrator. We have the ability to do whatever is needed but don't know what that might be.

    C: root is clearly visible. In attempting to manually move the EFile to the root it will engage the "You will have to provide administrative approval" dialog box.

  8. #8
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Access to C: drive

    I tested

    Please Login or Register  to view this content.
    in Excel 2010, Windows XP. No problem arises.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,658

    Re: Access to C: drive

    See:

    http://answers.microsoft.com/en-us/w...c-b4c1aca35aaf

    Indeed, there is a change in Windows 7 with regard to sharing the C drive. The default security template no longer include "Everyone," which is not the case in Vista.
    In order to share C drive with no authentication, you have to add "Everyone" to Security.
    Or just Google "accessing c drive in windows 7"

    Maybe this will resolve your problem.

    Regards

  10. #10
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Red face Re: Access to C: drive

    Okay, here is an update:

    I followed Mr Shucks advise and still nothing. I created the files successfully on a directory named C:\TTND and it worked but I need the files on C drive root. So I wrote code to move the files from C:\TTND to C:\ and I got a permission denied error.
    My ability to use Ninja Trader depends on two things:

    1) Finding the appropriate .txt files on C root
    2) Being able to "bat" the files over to the directory C:\Users\Steve\Documents\NinjaTrader 7\incoming

    Using vba to send the files directly to C:\Users\Steve\Documents\NinjaTrader 7\incoming does not work with Ninja since the time required to release the file to the directory is too long.

    I talked to the people at Ninja and they suggested two things:

    1) Goto cmd.exe and specify "Run as Administrator"
    2) Build a "Run as Administrator" parameter into the bat run syntax

    I have no clue how to do either of these things.

    Steve

  11. #11
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: Access to C: drive

    Have you tried turning off UAC?

  12. #12
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Access to C: drive

    So you ar looking for a solution to this problem:

    Using vba to send the files directly to C:\Users\Steve\Documents\NinjaTrader 7\incoming does not work with Ninja since the time required to release the file to the directory is too long.
    We could try to solve that before inventing a 'workaround'.

    What VBA-method do you use to send the file directly to 'C:\Users\Steve\Documents\NinjaTrader 7\incoming' ?

  13. #13
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Smile Re: Access to C: drive

    To romperstomper: UAC configuration did not help

    To snb: Since I was told that this is not possible to do by Ninja, I did not formulate any specific code. But then, they didn't know that snb was involved. If I could write the files directly to the "incoming" directly, I would be delighted. What code would you propose? This would be so simple if it worked.

    Thanks to everyone for their help.

    Steve

  14. #14
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Access to C: drive

    Where does the Ninja file reside ?

  15. #15
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Re: Access to C: drive

    snb

    just make up a txt file and send it to the incoming directory. That should suffice.

  16. #16
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Access to C: drive

    Please Login or Register  to view this content.

  17. #17
    Valued Forum Contributor SDruley's Avatar
    Join Date
    04-27-2009
    Location
    Conover, NC
    MS-Off Ver
    Excel 2010 64 bit
    Posts
    415

    Smile Re: Access to C: drive

    snb,

    This code looks clean and fast. I will try it this weekend. I have to go in for a medical procedure

    steve

  18. #18
    Registered User
    Join Date
    04-22-2012
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Access to C: drive

    Open Excel with administrator rights.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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