CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2000
    Posts
    23

    how to save doc file in html page

    hi,
    i am faced with a strange n peculiar stupid problem. I am giving a *.doc file in a href tag of html page and instead of opening the file save dialog box, its opening the file in Browser.

    CAn i somehow getover this problem, and prompt the user to save the doc file instead of opening it in browser window itself.

    somebody help me pls...

    rgds
    vinit

  2. #2
    Join Date
    Nov 1999
    Location
    Copenhagen, Denmark
    Posts
    265
    Just passed by. I'm not quite sure what you mean by

    I am giving a *.doc file in a href tag of html page
    Do you mean to say that the user presses a link looking like:

    http://foo.bar/baz.doc

    or that the user is directed to your page like:

    http://foo.bar/yourpage.html?document=baz.doc

    ?

    Either way, I think your cances of getting a reply is better in the "Client Side Scripting" forum. This doesn't look like a topic for a "General Discussion" ;-)

    Regards,
    S. Bro

  3. #3
    Join Date
    Nov 2000
    Posts
    23

    Unhappy

    i mean some thing like this < a href="abc.doc">XYZ </a>

    can i somehow prompt the user to save this file... clicking on XYZ.. now it is opening the file in browser itself

  4. #4
    Join Date
    Nov 1999
    Location
    Copenhagen, Denmark
    Posts
    265
    I think you can do something along the lines of (pseudocode):

    Code:
    <a href="abc.doc" onclick="doSave(this); return false;">XYZ </a>
    
    <script language="javascript>
    	function doSave(anchor) {
    		var w = new ActiveXObject("Word.Application");
            	w.Documents.Add(anchor.href.value);
            	var doc = w.Application.ActiveDocument; 	
            	doc.SaveAs(documentPath, 0);
            	doc.Close(0);
           	}
    </script>
    You'd have to roam USENET and check the MSDN office documentation for the Word automation API.
    Best regards,
    S. Bro

    "I would be happy to deal with my problems one at the time if they would only line up!"
    -Paul Cilwa, "Borland C++ Insider".

    Other useful fora some of which I ruthlessly clipboarded from other peoples footers.

    MSDN: http://search.microsoft.com/us/dev/default.asp
    WIN 32 Assembler: http://board.win32asmcommunity.net/
    RDBMS: http://www.dbforums.com
    Robert's Perl Tutorial: http://www.sthomas.net/roberts-perl-tutorial.htm
    Merriam-Webster Online: http://www.m-w.com/home.htm
    Writing Unmaintainable Code: http://mindprod.com/unmain.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured