我将这些Excel单元格格式化为逗号(E.G.9,000,000),我将其复制到Word中的固定表格中。我使用VB脚本(见下文)。但当值进入Word时,逗号消失。从9,000,000到9000000.我如何能够保留该号码的原始格式?谢谢。
Sub test()
Dim wdDoc As Word.Document
Dim wdApp As Word.Application
Dim tbl As Word.Table
Dim FileName As String
Dim iRow As Integer
Dim iCol As Integer
Path = ActiveWorkbook.Path
ChDir Path
Workbooks.Open FileName:=Path & "\Excel2.xlsx"
Set TARGET_FILE = Workbooks("Excel2.xlsx")
TARGET_FILE.Activate
Sheets("Sheet1").Select
SRC_A2 = Range("A2").Value
SRC_B2 = Range("B2").Value
FileName = "C:\Users\Desktop\Practice\Word.docx"
Set wdApp = New Word.Application
wdApp.Visible = True 'add this to see the Word instance and document
Set wdDoc = wdApp.Documents.Open(FileName)
Set tbl = wdDoc.Tables(1)
tbl.Rows(2).Cells(1).Range.Text = SRC_A2
tbl.Rows(2).Cells(2).Range.Text = SRC_B2
End Sub