Liebe Leute,
im Folgenden ein Teil unseres Projekts 1 (aus Excell einlesen und ein Word-Dokument erstellen). Es ist ein bisschen schlampig, aber es funktioniert.
lg, Birgit und Jana
TempDir = VALUE( "temp",,ENVIRONMENT)
say TempDir
FileName = TempDir || "" || "project.xlsx"
say filename
excelObject = .OLEObject~new("Excel.Application")
excelObject~visible = .true
book = excelobject~workbooks
book~open(FileName)
Sheet1 = excelObject~Worksheets[1]
myTitles="ABCDE"
lastLine = 6
do i = 2 to myTitles~length
cell.id = Sheet1~Range(A||i)
cell.frageA = Sheet1~Range(B||i)
cell.frageB = Sheet1~Range(C||i)
cell.email = Sheet1~Range(E||i)
Word = .OLEObject~New("Word.Application")
Word~Visible = .TRUE
Doc = Word~Documents~Add
Selection = Word~Selection
Selection~Style = "Title"
Font = Selection~Font
Font~Name="Verdana"
Font~Size="14"
Font~Bold = .TRUE
Selection~TypeText("This is the title for ID number "cell.id~value)
Selection~TypeParagraph
Selection~Style = "Normal"
Font~Name="Verdana"
Font~Size="12"
Selection~TypeText("Your answer on Question A was" cell.frageA~value "points")
FileNameWord = TempDir || "" || "Report for ID"|| (cell.id~value)||".docx"
Doc~SaveAs(FileNameWord)
Word~Quit
end