views:

4118

answers:

1

Hi, I have some code that opens a word document using VBScript on an ASP.net page:

set objWord = CreateObject("Word.Application")

objWord.Visible = True

objWord.Documents.Open "c:\inetpub\wwwroot\JSWordTest\test.doc", False, False, False

This works great but opens the word doc in another window. Ideally I would like to make this look as if it is contained in the current page perhaps in an IFrame. I have some other buttons which paste text into the word document when clicked.

I cannot just set the src of the iframe to the word document as need a reference to the word document (objWord) to allow me to paste text into it in real time again using Vbscript to do this.

Not sure if this is possible but any ideas/alternatives welcome?

Requirements: The word doc needs to be displayed from web browser

At the side of the word document will be some buttons which when clicked paste text into it

Thanks,

Alex

+2  A: 

You can use this technique to get the contents of the Word document without displaying any windows at all.

' Declare an object for the word application '
Set objWord = CreateObject("Word.Application")

objWord.Visible = False                 ' Don''t show word '
objWord.Documents.open("C:\test.doc")   ' Open document '
objWord.Selection.WholeStory         ' Select everything in the doc '
strText = objWord.Selection.Text     ' Assign document contents to var'
objWord.Quit False                   ' Close Word, don't save '

Once you've got the contents of the document in the variable you can do what you want with it as far as writing it out with a document.write or whatever method you want to use.

You can find more detail on the MS Word application object and its methods here: http://msdn.microsoft.com/en-us/library/aa221371(office.11).aspx

unrealtrip