|
-
August 25th, 2010, 06:32 AM
#1
print out function problem()
i m using below code..by using it i able to write asp data into word file n format it.but i m facing problen in print out..
please hav a look to below code....
view plaincopy to clipboardprint?
.................div data...................
<div id="printdiv" runat="server">
<table style="border: 5px solid #FF00FF; width:100%">
<tr>
<th align="left" style="background-color: #00FFFF">Vikas:Ji</th>
</tr>
<tr>
<th align="right" style="background-color: #800000">Vikas:Ji</th>
</tr>
<tr>
<th>Vikas:</th>
</tr>
<tr>
<th>Vikas:</th>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
</table>
</div>
..............to write dive data into word file
public void PrintControl()
{
try
{
String strr = printdiv.InnerHtml;
string strPath = "C:\\Documents and Settings\\hgtech\\Desktop\\WordForm\\abc.doc";
FileStream fStream = File.Create(strPath);
fStream.Close();
StreamWriter sWriter = new StreamWriter(strPath);
sWriter.Write(strr);
sWriter.Close();
edit_changes();
}
catch (Exception err)
{
//error.Text = err.Message;
}
}
.........................To format the word file...set left and top margin.........................
private void edit_changes()
{
Object missing = System.Reflection.Missing.Value;
Object fileName = "C:\\Documents and Settings\\hgtech\\Desktop\\WordForm\\abc.doc";
Word.Application wordApp = new Word.ApplicationClass();
Word.Document oDoc = new Word.Document(); ;
Object;
// oDoc.Close(ref missing, ref missing, ref missing);
if (File.Exists((String)fileName))
{
DateTime today = DateTime.Now;
Object isVisible = false;
wordApp.Visible = false;
oDoc = wordApp.Documents.Open(ref fileName, ref missing, ref
missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref
isVisible, ref missing, ref missing, ref missing, ref missing);
oDoc.Activate();
oDoc.PageSetup.TopMargin = 150.0f;
oDoc.PageSetup.BottomMargin = 200.0f;
}
object Background = true;
object Range = Word.WdPrintOutRange.wdPrintAllDocument;
object Copies = 2;
object PageType = Word.WdPrintOutPages.wdPrintAllPages;
object PrintToFile = false;
object Collate = false;
object ActivePrinterMacGX = missing;
object ManualDuplexPrint = false;
object PrintZoomColumn = 1;
object PrintZoomRow = 1;
oDoc.Close(ref missing, ref missing, ref missing);
oDoc.PrintOut(ref Background, ref missing, ref Range, ref missing,
ref missing, ref missing, ref missing, ref Copies,
ref missing, ref PageType, ref PrintToFile, ref Collate,
ref missing, ref ManualDuplexPrint, ref PrintZoomColumn,
ref PrintZoomRow, ref missing, ref missing);
-
August 26th, 2010, 08:04 AM
#2
Re: print out function problem()
That's nice. Just put all your code here and expect everyone to magically fix all your errors. Sorry, it doesn't work like that. Tell us exactly where your problem is and what it is what you're trying to do. Please also use [CODE] tags when posting code.
-
August 27th, 2010, 02:29 PM
#3
Re: print out function problem()
You need to supply values to the parameters:
Code:
oDoc.Close(ref missing, ref missing, ref missing);
oDoc.PrintOut(ref Background, ref missing, ref Range, ref missing,
ref missing, ref missing, ref missing, ref Copies,
ref missing, ref PageType, ref PrintToFile, ref Collate,
ref missing, ref ManualDuplexPrint, ref PrintZoomColumn,
ref PrintZoomRow, ref missing, ref missing);
Reply With Quote
What is this? "ref missing"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|