So I'm trying to do the unthinkable and actually do some basic calculations in a word table, without having to resort to Excel. It's for the invoice generator I've been building for a while, and this is pretty much the last thing I have left.
The questions is simple.. how do you multiply a number from one cell with a number from a second cell, in order to get a result in the third cell? I just can't figure it out, yet it sounds very simple. Ideally it would execute after refocusing from one cell to another.
Any ideas?
EDIT:
Well, that really was easy. All I needed was the Val function. Here's the code:
Dim qty1 As Integer
Dim qty2 As Integer
Dim qty3 As Integer
Dim price1 As Integer
Dim price2 As Integer
Dim price3 As Integer
qty1 = Val(ActiveDocument.Tables(5).Cell(2, 2).Range.Text)
qty2 = Val(ActiveDocument.Tables(5).Cell(3, 2).Range.Text)
qty3 = Val(ActiveDocument.Tables(5).Cell(4, 2).Range.Text)
price1 = Val(ActiveDocument.Tables(5).Cell(2, 3).Range.Text)
price2 = Val(ActiveDocument.Tables(5).Cell(3, 3).Range.Text)
price3 = Val(ActiveDocument.Tables(5).Cell(4, 3).Range.Text)
ActiveDocument.Tables(5).Cell(2, 4).Range.Text = qty1 * price1
ActiveDocument.Tables(5).Cell(3, 4).Range.Text = qty2 * price2
ActiveDocument.Tables(5).Cell(4, 4).Range.Text = qty3 * price3