Ich mache ein Wort Automatisierung über Ruby und bin relativ unerfahren mit ihm. Ich versuche, meinen Code jetzt functionise und ich auf diesem Fehler kämeRuby - WIN32OLE Funktionserstellung
NameError: undefined local variable or method `doc' for main:Object
from (irb):148:in `create_table'
from (irb):152
from C:/Ruby192/bin/irb:12:in `<main>'
Was ich bin aus diesem Beispielcode immer geklopft i
up#Get the correct packages
require 'win32ole'
#setting up the Word
word = WIN32OLE.new('Word.Application')
#Shows the word Application
word.Visible = true
#Setting doc to the active document
doc = word.Documents.Add
doc = word.ActiveDocument
def create_table
doc.Tables.Add(word.Selection.Range, 4, 2) #Creates a table with 3 rows and 2 columns
doc.Tables(1).Borders.Enable = true
end
create_table
Wenn Sie daran gedacht hätten, Ihren Code einzurücken, wäre das Vergessen, 'doc' als Parameter zu übergeben, eindeutiger. –