Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write to a folder with no "WRITE" permissions

Status
Not open for further replies.

JazzyLee

Programmer
Jan 24, 2002
47
US
I wrote a VB macro in Excel 2000 and have a major problem. I need to save the formatted Excel file in a folder that the person running the macro has no access to. Because of security issues at my company, I cannot allow the person running the macro and creating the data file, to have access to this file. Is there a set of codes that can be written in the macro that would use the permissions from a service account (or some other individual with access) to write the workbook to a specified folder? Something to the effect of using a logonid and password to write to the target folder. If this is confusing, welcome to my world. Any assistance would be very much appreciated.
 
You certainly can have a macro interacting with a folder that a user does NOT have permission rights to.

You can use the Shell function to use RunAs, as in:

Shell("C:\WINNT\System32\RunAs /profile /user:<username@domain.net> <command>", 0)

The username must have rights permission to whatever the command is to do. That command can run an executable from the unaccessible folder. It seems to be able to copy files. I seem to be having problems with running a batch file to copy files. I tried to have the macro first write a file to a temp folder, then use Shell(RunAs) to move the files. When you use RunAs in a macro it opens a cmd window where you have to type in the password of the RunAs username. I even tried to put a separate copying macro in Word's normal.dot and RunAs an instance of Word (under the admin account) with that as the startup macro. Hmmm.

Partially there, but have to do something else right now. This may (I hope) point you in some direction. I am going to flag this, as I am curious if this gets picked up and a full solution found.



Gerry
 
Gerry,
What I need to do is to open an Excel workbook from a folder that the person running my macro has NO "WRITE" (only READ) permission on. However, I need to delete the worksheet with the data from the workbook after the information has been processed and save it back to this folder but I am having problems because of the "READ ONLY" permission assigned to the client. I am not sure how to code this RunAs scenario you are pointing me to. Can you give me an example?

Thanks much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top