计划的 MS Access 宏来运行查询并导出到 CSV [英] Scheduled MS Access macro to run query and export to CSV

查看:89
本文介绍了计划的 MS Access 宏来运行查询并导出到 CSV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Windows 计划任务来打开 MS Access DB (.mdb),该数据库具有运行一些查询的 AutoExec 宏,然后将其导出到 .csv 以替换已经存在的 .csv 文件.

I'm trying to get a windows Scheduled Task to open up MS Access DB (.mdb) which has an AutoExec macro that runs some queries and then exports it to a .csv replacing the .csv file that is already there.

从命令提示符我可以运行:

From the command prompt I can run:

"C:\Program Files (x86)\Microsoft Office\root\Office16\MSACCESS.EXE" "/Path to my Access DB"  

并且一切正常.Access 打开,运行查询,并用查询中的新数据替换 .csv.

and everything works perfectly. Access opens up, runs the query, and replaces the .csv with new data from the query.

当我尝试通过计划任务访问执行此操作时,只会删除 .csv 文件而不替换它并返回错误操作员或管理员已拒绝请求".

When I try to do this with a Scheduled Task access just deletes the .csv file without ever replacing it and returns the error "the operator or administrator has refused the request".

有什么想法吗?我一直在寻找一种快速获取数据的方法,但我觉得我最好编写一些 Python 来连接到 Access.

Any ideas? I was looking for a quick way to get the data but I feel like I might be better off just writing some python to connect to Access.

推荐答案

我这周能够回到这个问题,终于找到了解决方案.

I was able to return to this problem this week and finally found the solution.

问题归结为计划任务.这是一个本地机器权限问题,并使用解决该问题的正确域运行任务.

The problem came down to the scheduled task. It was a local machine permissions issue and running the task with the correct domain that solved it.

首先要修复本地计算机权限,我必须确保运行任务的用户具有作为批处理作业登录"权限.位于控制面板 -> 管理工具 -> 本地安全策略\本地策略\用户权限分配 ->作为批处理作业登录"

First to fix the local machine permission I had to make sure that the user running the task had "Log on as a batch job" permissions. Found at Control Panel -> Admin Tools -> Local Security Policy\Local Policies\User Rights Assignments -> "Log on as a batch job"

第二,因为我在域中,所以计划任务必须由域用户明确创建.我必须在创建任务期间手动查找域上的用户,并删除由任务计划创建向导自动填充的用户.

Second, because I was on a domain the schedule task had to be explicitly created by the domain user. I had to manually find the user on the domain during the creation of the task and remove the user that was auto populated by the task scheduled creation wizard.

这篇关于计划的 MS Access 宏来运行查询并导出到 CSV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆