我正在使用一个excel / xlwings工具来练习我的心理数学,使用我以前用来在命令行运行的旧python脚本。尝试运行VBA宏时,出现以下错误:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'Training_factoring'
我将提供一些清单,以便为该请求提供一些背景信息:
这是我的代码示例:
Sub PracticeStart()
Dim i As Integer
Dim Response As Long
Do While True
RunPython ("import Training_factoring; Training_factoring.DistributionTwoDigit()")
Response = InputBox("Answer? ")
ActiveWorkbook.Worksheets("practice").Range(i + 2, 1).Value = Response
i = i + 2
Loop
End Sub
def DistributionTwoDigit():
wb = xw.Book.caller()
x = random.randrange(10, 99, 1)
y = random.randrange(10, 99, 1)
i = 0
i =+ 2
wb.sheets[0].range("A1").value = "Distribution (Two-Digit)"
wb.sheets[0].range(i+1,1).value = '{}*{}'.format(x, y)
RunAnswer()
wb.sheets[0].range(i+3,1).value = (x*y)
wb.sheets[0].range(i+4,1).value = '-------------------------------'
x = random.randrange(10, 90, 1)
y = random.randrange(10, 90, 1)