我想使用相同的分隔符和格式将excel文件的内容复制到剪贴板,而不管用户配置如何.
这是我的宏:
Private Sub CommandButton1_Click() 'save number separators Dim d, t, u d = Application.DecimalSeparator t = Application.ThousandsSeparator u = Application.UseSystemSeparators 'set number separators With Application .DecimalSeparator = "." .ThousandsSeparator = "," .UseSystemSeparators = True End With 'create temporary copy ActiveSheet.Copy 'set number format ActiveSheet.Range("H2:I150").NumberFormat = "0.0000000000" [...] 'copy sheet to clipboard ActiveSheet.Range("A1:O150").Copy 'disable messages (clipboard) Application.DisplayAlerts = False 'close temporary copy ActiveWorkbook.Close SaveChanges:=False 'reenable messages Application.DisplayAlerts = True 'reset original separators With Application .DecimalSeparator = d .ThousandsSeparator = t .UseSystemSeparators = u End With End Sub
如果我最后没有重置原始分隔符,一切正常,但这对我来说是不可接受的.
如果我重置了分隔符(如此代码中所示),那么剪贴板的内容将具有用户特定的分隔符,而不是我在开头时定义的分隔符.
有想法该怎么解决这个吗?