私はフォーム内にフォームを持っています。オブジェクトにはExcelファイルが含まれています。 次に、ワークシートのフィールドの合計を計算し、そのフォームのフィールドに合計を表示するボタンがあります。それをどのようにコード化するのですか?あなたはノーツクライアントとマシンから使用されるフォーム上でこれをやっている場合はlotusscriptを使用してExcelのセルの合計を計算します。
doc.total = totalr
私はフォーム内にフォームを持っています。オブジェクトにはExcelファイルが含まれています。 次に、ワークシートのフィールドの合計を計算し、そのフォームのフィールドに合計を表示するボタンがあります。それをどのようにコード化するのですか?あなたはノーツクライアントとマシンから使用されるフォーム上でこれをやっている場合はlotusscriptを使用してExcelのセルの合計を計算します。
doc.total = totalr
:アイデアは、この
totalr = SUM(A51 A2)のようなものですノーツクライアントを実行すると、VBAを使用することができます。ファイルをユーザーのハードドライブに抽出し、Excelで開き、列の最下部にセルを追加してSUM()関数を配置し、その新しいセルの値を取得し、UIDOCのフィールドを更新してから、温度を消去しますファイル。
以下のコードでは、Excelファイルを含むRichTextフィールド(Excelファイルを含む)、Excelファイルからの合計値を含む「Sum」というフィールド、およびコード。さらに、コードを動作させるためには、添付ファイルとともに文書を保存する必要があります。
希望します。
Sub Click(Source As Button)
On Error Goto errorhandler
Dim s As New NotesSession
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Dim doc As NotesDocument
Set doc = uidoc.Document
Dim rtitem As NotesRichTextItem
Dim isfileopen As Boolean
Dim filename As String, rows As Double, cols As Double, colToSum As String, c As Integer
Dim xlApp As Variant, xlWorkbook As Variant, xlSheet As Variant, pathname As String
isfileopen = False
'convert column letter to number
colToSum = "A"
c = Asc(colToSum) - 64
'extract file
pathname = s.GetEnvironmentString("Directory", True) & "\"
Set rtitem = doc.GetFirstItem("excelfile")
If Not (doc.HasEmbedded) Then
Msgbox "There are no file attachments on this document"
Goto ExitGracefully
End If
Forall o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
filename = pathname & o.Name
Call o.ExtractFile(filename)
End If
End Forall
'open file
Print "Opening file " & filename & "..."
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Open filename
isfileopen = True
'get sheet
Print "Gathering data ..."
Set xlWorkBook = xlApp.ActiveWorkbook
Set xlSheet = xlWorkBook.ActiveSheet
xlSheet.Cells.SpecialCells(11).Activate
rows = xlApp.ActiveWindow.ActiveCell.Row
cols = xlApp.ActiveWindow.ActiveCell.Column
'add a row and put the sum() formula there
Print "Computing sum with Excel..."
xlSheet.Cells(rows+1, c).value = "=SUM(" & colToSum & "1:" & colToSum & Cstr(rows) & ")"
'update UI doc
Call uidoc.FieldSetText("Sum", Cstr(xlSheet.Cells(rows+1, c).value))
exitgracefully:
'close excel
Print "Closing Excel..."
If Not xlWorkbook Is Nothing Then
xlWorkbook.Close False
End If
If Not xlApp Is Nothing Then
xlApp.DisplayAlerts = False
xlApp.Quit
Set xlApp = Nothing
End If
If isfileopen Then
'remove temp file
Print "Removing " & filename
Kill filename
End If
'done
Print "Done"
Exit Sub
errorhandler:
Msgbox Error & " line " & Erl
Exit Sub
End Sub