且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VBA字符串变量包含其他变量

更新时间:2023-02-26 11:12:34

您无法像使用其他某些语言一样轻松地在VBA中评估随机代码.使用替换的令牌会更好.

You can't easily evaluate random pieces of code in VBA like you can in some other languages. You'd be better off using tokens which you replace.

在您的文本文件中:

email_body|Final Reports will be distributed on or after {month} 10th.

那么您就可以

Debug.Print Replace(MessageBody, "{month}", Me.cbo_Month.Column(0))