When I export a page to MS Word, Word cuts off some of my data on the due to a problem with the margins. I've checked the margins under "page setup" in Access as well as in Word, but for whatever reason, Word won't use the new margin settings. As always, thanks in advance for your help.

Recommended Answers

All 2 Replies

Write Response headers,

Response.Clear();
        Response.ClearHeaders();
        Response.AddHeader("Pragma", "public");
        Response.AddHeader("Expires", "0");
        Response.AddHeader("Content-Type", "application/word");
        Response.AddHeader("Content-Disposition", "inline; filename=sample.doc");
        Response.Write("<table><tr><td><h1>No</h1></td></tr></table>");
        Response.Flush();
        Response.End();

Write Response headers,

Response.Clear();
        Response.ClearHeaders();
        Response.AddHeader("Pragma", "public");
        Response.AddHeader("Expires", "0");
        Response.AddHeader("Content-Type", "application/word");
        Response.AddHeader("Content-Disposition", "inline; filename=sample.doc");
        Response.Write("<table><tr><td><h1>No</h1></td></tr></table>");
        Response.Flush();
        Response.End();

hi i tried dat bt der is problem with margin

string style = "<style>body {margin-top: 100px; margin-right: 40px; margin-bottom: 10px; margin-left: 70px;}</style>";

Response.Clear();

Response.AddHeader("content-disposition", "attachment;filename=BabulEnterprises" + ".doc");

Response.Charset = "";

// Response.Cache.SetCacheability(HttpCacheability.NoCache);

Response.AppendHeader("Content-Type", "application/msword");

StringWriter stringWrite = new StringWriter();

HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);


Response.Write(style);

pnlForm.RenderControl(htmlWrite);

Response.Write(stringWrite.ToString());

Response.End();

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.