单词VBA和货币 [英] Word VBA and Currency

查看:103
本文介绍了单词VBA和货币的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好


我有一个带有VBA脚本的Word文档,用于在Word文档中填充Userform到Table中的数字。这很好用,但我遇到的问题是数字的货币格式。如果doc中的格式与我的PC上的区域设置
相同,则效果很好,但是当模板在具有不同区域设置的计算机上运行时,特别是在十进制符号和数字分隔符上运行时会出现问题。我无法在Word中为此模板强制执行此设置,以便宏可以在
任何计算机上运行。此外,Word 2016没有为Word设置小数和分隔符号的选项。


有人可以帮助我解决这个问题我已经和我斗争了几个星期了。  ;


亲切的问候


Andrea

解决方案

我为Word 2003做了类似的事情。 现在可能有更好的方法。 我只需要使用几种不同的格式。


你可以用这个获得国家代码:


cCode = Application.International(xlCountrySetting )


然后我为每个国家代码创建了一个带格式化选项的函数


fValue =格式(值,"#,## 0.00;( #,## 0.00)")


Hi

I have a Word doc with VBA script to populate numbers from a Userform to a Table in the Word doc. This works perfectly, but the problem I have is with the currency format of the number. It works well if the format in the doc is the same as the regional settings on my PC, but the problem comes in when the template runs on a machine with different regional settings, specifically on the decimal symbols and number separator. I cannot a way to force this setting in Word just for this template so that the macro works from any machine. Also Word 2016 doesn't have the option to set the decimal and separator symbol just for Word.

Can someone please help me with this problem I have been battling with for several weeks now. 

Kind regards

Andrea

解决方案

I did something like this for Word 2003.  There is probably a better way now.  I only had to do it for a few different formats.

You can get the country code with this:

cCode = Application.International(xlCountrySetting)

Then I created a function with formatting options for each country code

fValue = Format(value, "#,##0.00;(#,##0.00)")


这篇关于单词VBA和货币的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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