2
我正在使用發送鍵來選擇所有數據並從另一個應用程序複製它。我的目標是將這些數據粘貼到word中並保存爲PDF格式。我似乎遇到的問題是,使用Microsoft interop,需要您編程格式化數據。如果我從其他應用程序複製數據,並將其手動粘貼到真實的文檔文檔中,則格式會保留自身。如何將數據粘貼到Word文檔中
有沒有一種方法可以輕鬆地將我的剪貼板數據與這段代碼一起使用?
Try
Dim oWord As Word.Application
Dim oDoc As Word.Document
'Start Word and open the document template.
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
oPara1 = oDoc.Content.Paragraphs.Add
oPara1.Range.Text = Clipboard.SetText
'TIll Above your entire odoc is formatted
'From below I will save it to my own code
Dim newdoc As Word.Document
newdoc = oDoc
newdoc.SaveAs2("K:\file.pdf", Word.WdSaveFormat.wdFormatPDF)
'All done. Close this form.
'BSPGlobals.DataBase.Contact.ExitApp()
MessageBox.Show("Print to Doc Done.")
Catch ex As Exception
MessageBox.Show("Error at Printing the bill." & vbCrLf & ex.Message)
End Try
謝謝。有用! – user3753620