Excel - 將內容顯示為HTML以便傳輸到Lotus Notes

[英]Excel - Show content as HTML for transfer to Lotus Notes


I have an Excel VBA script that generates an HTML document (no JS or CSS involved) based on spreadsheet values. I have the HTML contents stored as a string inside a cell.

我有一個Excel VBA腳本,它根據電子表格值生成HTML文檔(不涉及JS或CSS)。我將HTML內容存儲為單元格內的字符串。

I'd like to have this content to be sent as an HTML email from Lotus Notes. Right now, I have to do the following: 1. Copy the cell contents to an .html file 2. Open the .html file in Chrome 3. Copy the contents from Chrome 4. Paste the contents to Lotus Notes Composer

我希望將此內容作為來自Lotus Notes的HTML電子郵件發送。現在,我必須執行以下操作:1。將單元格內容復制到.html文件2.在Chrome中打開.html文件3.從Chrome復制內容4.將內容粘貼到Lotus Notes Composer

My objective here is to trim down this workflow to reduce the number of steps.

我的目標是減少此工作流程以減少步驟數。

The ideal case would be for me to be able to copy and paste directly from Excel to Lotus Notes but all I can manage to get is some table cell instead of an HTML-formated block pasted.

理想的情況是我可以直接從Excel復制並粘貼到Lotus Notes,但我可以設法獲得的是一些表格單元格而不是粘貼的HTML格式的塊。

The second-most ideal case would be for the cell to open a browser tab with the HTML content. I would like to avoid doing server-side scripting for portability so POST, GET, and etc are largely out of question.

第二個最理想的情況是單元格打開帶有HTML內容的瀏覽器選項卡。我想避免為可移植性做服務器端腳本,因此POST,GET等基本上是不可能的。

Any advice on this matter would be appreciated.

關於這個問題的任何建議將不勝感激。

3 个解决方案

#1


0  

The Notes client's UI isn't expecting raw HTML as input, so I think you're going to have fair amount of work to do in order to get around that. Most likely you're going to have to use the Notes OLE classes to create a draft message (i.e., a NotesDocument without a SentDate or DeliveredDate item) in the user's mail file, give it an HTML body (using the NotesMimeXXX classes, and give it a unique subject, then save the draft, use NotesDatabase.getView to open the Drafts view, walk through the view until you find the entry with the correct subject, open that entry as a NotesDocument, and finally use the NotesUIWorkspace.EditDocument method with the correct NotesDocument argument to open for edit in the UI.

Notes客戶端的UI不期望將原始HTML作為輸入,因此我認為您需要做大量的工作才能解決這個問題。很可能你將不得不使用Notes OLE類在用戶的郵件文件中創建一個草稿消息(即,沒有SentDate或DeliveredDate項的NotesDocument),給它一個HTML主體(使用NotesMimeXXX類,並給出它是一個獨特的主題,然后保存草稿,使用NotesDatabase.getView打開草稿視圖,遍歷視圖,直到找到具有正確主題的條目,將該條目作為NotesDocument打開,最后使用NotesUIWorkspace.EditDocument方法在UI中打開以進行編輯的正確NotesDocument參數。

#2


0  

If you know where the spreadsheet is, and what values you want from it, my solution would be to write a LotusScript routine behind an action button in Memo form.

如果您知道電子表格的位置以及您希望從中獲得的值,我的解決方案是在Memo表單中的操作按鈕后面編寫LotusScript例程。

The purpose of this code would be to open the Excel file using OLE, read the necessary data and build a NotesRichTextItem in a temporary document. Then Save the temp document, and close the Excel sheet. Use the undocumented "NotesUIDocument.ImportItem" method to copy the saved message to your current notes document, then delete the temp document. Done.

此代碼的目的是使用OLE打開Excel文件,讀取必要的數據並在臨時文檔中構建NotesRichTextItem。然后保存臨時文檔,並關閉Excel工作表。使用未記錄的“NotesUIDocument.ImportItem”方法將保存的消息復制到當前的備注文檔,然后刪除臨時文檔。完成。

Once you've opened the worksheet in OLE the code will be very similar to your macro, but you won't be able to use ActiveDocument or Application etc, and you'll have to declare or replace any Excel VBA constants you've used.

一旦在OLE中打開工作表,代碼將與您的宏非常相似,但您將無法使用ActiveDocument或Application等,並且您必須聲明或替換您使用過的任何Excel VBA常量。

Phil

#3


0  

There are different ways to achieve what you want. I would use OLE/COM:

有不同的方法來實現你想要的。我會使用OLE / COM:

In your Excel- Script just write code like the following:

在Excel腳本中只需編寫如下代碼:

Dim ws As Object
Dim ses as Object
Dim mailDb as Object
Dim memo as Object
Dim uidoc as Object

REM "These lines will start the Lotus Notes- Client if it is not already started"
Set ws = CreateObject("Notes.NotesUIWorkspace")
Set ses = CreateObject("Notes.NotesSession")

REM "you might need these lines to get the Lotus Notes Window in focus"
Set WshShell = CreateObject("WScript.Shell")

REM "In version 9 the windowtitle will be different..."
WshShell.AppActivate ("Lotus Notes")

REM "Get the users maildatabase"
Set mailDb = ses.GetDatabase("","")
Call mailDb.OpenMail

REM "Create a new mail"
Set memo = mailDb.CreateDocument
Call memo.ReplaceItemValue( "Form", "Memo" )

REM "Open the mail in frontend"
Set uidoc = ws.EditDocument(True,memo)

REM "Switch to Body field"
Call uidoc.GotoField( "Body" )

REM "Here comes the magic..."
Call uidoc.Import( "HTML File", "C:\Temp\yourHtml.html" )

You need to write the html code to the filesystem (temporary, delete it afterwards), but that way you do not need to take care for conversion to mime, etc...

您需要將html代碼寫入文件系統(臨時,之后將其刪除),但這樣您就不需要注意轉換為mime等...


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2014/01/17/72a34035d353fb25309738fa9adbc87b.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com