0
我將這些Excel單元格式化爲逗號(例如9,000,000),我將其複製到Word中的固定表格中。我使用VB腳本來做到這一點(見下文)。但是,當價值進入Word時,逗號消失。從9,000,000到9000000.我將如何保留該號碼的原始格式?謝謝。VB:將Excel單元複製到Word並保留Excel格式
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
這似乎不是VB腳本(如問題中提到的)或VB.Net(標記爲)。 – YowE3K