我编写的代码计算if-then条件值,然后出现在消息框中。如何将消息框导出到MS Word?是否有一个函数,而不是Msgbox,我可以导出到MS Word?我可以将它从Debug.print转换为word吗?
myData_B
答案 0 :(得分:2)
我将这种类型的代码用于我的作业
Sub demo()
'If trueCount > 0 Then
Cst = "1"
hrs = "12"
scope = "none"
Data = "Cost: " & Cst _
& vbNewLine & "Hours: " & hrs _
& vbNewLine & "Scope: " & scope
'MsgBox Data
Dim objWord
Dim objDoc
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add
objWord.Visible = True
objDoc.Range.Text = Data
End Sub