• TeachMe

    (@teachme)


    Hi everyone,

    what I’m trying to do is build a form in wordpress where users can fill in fields. I would then use that input to fill in a Word document at the appropriate place using textboxes, and then ahve the user get the option to download that word file.

    I know there are many plugins for forms, but apart from that, I’m not sure where to start to reach my goal.

    Any clues?

Viewing 9 replies - 1 through 9 (of 9 total)
  • sunlitlaz

    (@sunlitlaz)

    Let me clarify, you want your users to enter data into text boxes on a form and when they submit, have them then be able to get that data and form back as a word doc?

    Why are you trying to do that versus letting the text display on a page and letting the user copy and paste into their own word doc for example?

    Thread Starter TeachMe

    (@teachme)

    The main reason is to keep the formatting and the wording the same. I want to create something similar to the “mailmerge” function in Word. Is this doable?

    sunlitlaz

    (@sunlitlaz)

    Well, from my experience the function of collecting information and creating a word document is definitely doable, the hard part though, at least I think it will be, is the formatting of the “form” that you are trying to make. For example, if you were collecting data to generate a filled out tax form that looked just like the standard tax form, that would be pretty hard to do. The formatting of most forms is pretty tight.

    What I have done in the past is take my data, whether from a database or wherever and generate an HTML file formatted however I like. This is because HTML is a file format of MS Office. I don’t know if it still is, but at one point I think it was even the default format.

    Anyway, all I had to do was create my HTML file and when I saved it, insert the MS Word HTML headers at the top that told Office that, that particular HTML file was indeed a word file. If you didn’t, it would get treated like any other HTML file. Insert those magic lines in the header though and bingo! Now when you save it or click on it, with the proper file extension of course (like .doc or .docx), and Word sees it as a long lost child come home.

    Hope that helps!

    Thread Starter TeachMe

    (@teachme)

    that sounds great sunlitlaz!

    did you write about it in an article? I’d like to get more information about what you did…

    I’m not very experienced in this matter, so i’d love to get as much information as I can!

    sunlitlaz

    (@sunlitlaz)

    I haven’t written about that before … at least not that I remember, getting old is fun. But now that you mention it, it might make a good article for my tech blog.

    I’ll see if I can find the headers that I used and any other information from when I did that (it was a year ago or so, for a website that I created), so I can share it with you if you’d like.

    WPyogi

    (@wpyogi)

    Did you look at the plug-ins in detail. Some may already be able to do what you want…

    Thread Starter TeachMe

    (@teachme)

    yeah there are many plugins for forms, but not so many that allow to be input into Word files i find

    Thanks sunlitlaz! let me know!

    sunlitlaz

    (@sunlitlaz)

    Teach –

    I have the headers and PHP code that I used to create a word doc and then pop it up in the browser or open it like the user clicked on it. This was after all after they clicked on a link to get the file, but I had to create it first.

    It’s over at Pastebin [Link], and hopefully is pretty self explanatory. Good luck, I am sure you will get it working in no time. Just the headers themselves are there too [Link].

    Thanks

    Hi sunlitlaz,

    Would you use the code above to generate a textfile to send as a notification attachement. As in: user fills out a form, admin gets email with a txt attachment holding the form information.
    How would you create this attachment?

    Thanks already for this code, helped me think about my project in a different way 😉

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘How do you build a self-fillable form’ is closed to new replies.