Most scholars believe that the books of the Old Testament reached their present form some time in the first millennium BC, although they contain much older material, some of which was in written form and some of which was orally transmitted.
Christians don't generally hold to a 'dictation' model of divine inspiration, in which an angel, or the Holy Spirit, instructs a human recipient what to write or say, word by word. Traditionally Christians have believed that the human authors spoke or wrote what they understood to be the truth, it flowed from their own existing theological understanding and their own insights into creation, including human nature. For example, we see Jesus caught up in debates and arguments, in which he answers questions or accusations in much the same way that anyone else would, sometimes appealing to scripture, sometimes to common-sense. We believe that God indwells the whole process of thought that goes into the creation of new spiritual teaching. If you like, he doesn't dictate the words 'God is love', he creates a human being whose whole life - education, maturity, passion - lead him to conclude that 'God is love' and that he must say so. That human process can perfectly well include the creative use of existing materials, whether those materials are written or spoken, whether they are historical documents about actual people, or mythic materials from other cultures, or fictions to illustrate a point. We regard the whole process as 'theopneustos' or 'God-breathed' (as the New Testament puts it - the word usually translated 'inspired'). That is to say the same God who breathes life into a person, breathes out the word of God through that person's life and work.