变量的WITHIN字符串? [英] Variable's WITHIN strings?

查看:120
本文介绍了变量的WITHIN字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在整理一个Excel的COM加载项,使我可以利用工作簿中的信息直接从excel发送电子邮件.

我遇到了砖墙,因为我希望用户在应用程序中(某种程度上)编写代码.这将存储在一个单元格中,并在以后重新打开时进行检索.

我已经声明了字符串变量(var1,var2,var3),并为它们分配了正确的值.这是我要在电子邮件正文中编写的示例:

I''ve been putting together a COM add-in for excel that will allow me to send emails directly from excel utilizing information within the workbook.

I have run into a brick wall because I want the user to (sort of) write code within the app. This will be stored within a cell and retrieved when reopened at a later date.

I have declared string variables (var1,var2,var3) and have assigned these the correct values. Here is an example of what I want to write this within the email message body:

"Hello " & var1 & "," & vbNewLine _
& "Today sales were: " & var2 & " " & var3 & "."



现在的问题是,该字符串已分配给变量,并且即使使用正确的和&用法",程序也无法确认var1,var2,var3或VbNewLine.
对如何完成此任务有任何想法吗?并在COM插件中保持我想要的灵活性?

谢谢
Michael



Now the problem is that this string is assigned to a variable, and the program is not acknowledging the var1,var2,var3 or VbNewLine even with proper " and & usage.

Any thoughts on how I could accomplish this task? And maintain the flexibility I want within the COM addin?

Thank you,
Michael

推荐答案

您不能这样做.除非您编写代码,否则绝不会扫描字符串中的变量名,也不会替换其内容.

更好的选择是跳过编写代码"垃圾(用户始终不会编写代码),并用对用户更有意义的标记替换那些"var1","var2"或任何其他内容.

像你好{fristName}"之类的东西.然后,您可以搜索这些标签并将其替换为所需的值. Word就是这样做的.
You cannot do that. Strings are never scanned for variable names and their contents are never replaced unless you write code to do so.

A better option would be to skip the "writing code" garbage (users never write code anyway) and replace those "var1" "var2" or whatever with tags that make more sense to the user.

Something like "Hello {fristName}". Then you can search and replace those tags with the values required. This is how Word does it.


这篇关于变量的WITHIN字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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