我可以使用VBA来“传递"邮件吗?Excel中与外部数据库连接的密码? [英] Can I use VBA to "pass" a password to an external database connection in Excel?

查看:61
本文介绍了我可以使用VBA来“传递"邮件吗?Excel中与外部数据库连接的密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用VBA隐藏在Excel工作表中设置的数据连接的密码.由于Excel将密码以纯文本格式存储到外部数据源,因此我想让VBA调用表的刷新并提供密码.我记录了刷新表和输入密码的宏,但令我沮丧的是,它似乎省略了密码部分……这是我唯一需要的部分.

I am trying to use VBA to hide the password for a data connection I have set up in an Excel sheet. Since Excel stores passwords to external data sources in plain text, I wanted to have VBA call the refresh of the table and supply the password. I recorded a macro of my refreshing the table and entering the password, but to my dismay, it seems it omitted the password part...which was the only part I needed.

Sheets("RAW").Select
Range("R16").Select
Selection.ListObject.QueryTable.Refresh BackgroundQuery:=False

我无法在线找到任何解决方案.我隐约意识到可以通过VBA直接建立数据库连接,但是a)有很多数据透视表和数据表之外的内容; b)我不确定我是否足够理解DB来解决所有这些问题.谁知道VBA是否可以通过某种方式将密码传递"到外部数据连接?

I am unable to find any solutions to this online. I am vaguely aware that a DB connection can be set up directly through VBA, but a) there are a lot of pivots and whatnot built off of the data table and b) I'm not sure I understand DB's enough to figure all that out. Does anyone know if there is any way to have VBA "pass" the password to an external data connection?

推荐答案

答案确实是按照OpiesDad和KrisB的建议更新VBA中的连接字符串.

The answer was indeed to update the connection string in VBA, as suggested by OpiesDad and KrisB.

这篇关于我可以使用VBA来“传递"邮件吗?Excel中与外部数据库连接的密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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