|
Hello,
I am using C# (Interop.Word).
I am saving the document at the hard disc by using some predefined template
and the Document.SaveAs function.
When the user will open the document I have saved (by regular way, by
doubleclicking the Word file in the Explorer) I want the document to be
opened at the Print Layout and not at the Normal, as it somewhy does now.
How can I programmatically force the Word to do this?
In C# I do not open Word, so I do not have ActiveWindow...???
Thanks a lot.
|
|
|
|
|
Basically, you can't do this for individual documents without writing a Word addin that runs at startup, but then you'll have to recognise that the document is one that you want opening in this particular way.
|
|
|
|
|
Thanks a lot for your quick answer,
Actually I have encountered several problems working with Word.
Please see if you can help me resolve them.
My application creates documents (Microsoft.Interop.Word.Document) each one according to another template(.dot on the hard disc). Then I have to merge them and save as a single .doc (while the original formatting is saved). I do this in the following way:
Range rangeTrg = ((Document)(m_WordDocsArr[0])).Content;
object brk = WdBreakType.wdSectionBreakNextPage;
object rngEnd = WdCollapseDirection.wdCollapseEnd;
rangeTrg.Collapse(ref rngEnd);
for (int i = 1; i < m_WordDocsArr.Count; i++)
{
rangeTrg.InsertBreak(ref brk);
Range rangeSrc = ((Document)(m_WordDocsArr[i])).Content;
rangeTrg.FormattedText = rangeSrc.FormattedText;
rangeTrg.Collapse(ref rngEnd);
}
Problem #1:
If there is one document in m_WordDocsArr, afterwords when I open the .doc by doubleclicking it, Word opens it in Print Layout, if there is more than one document in m_WordDocsArr, Word opens it in Normal layout.
Why?
Problem #2:
The original templates I use have headers and footers.
Somewhy (???) the merged doc has the first document's headers and footers.
I tryed to save the headers and footers of the original docs before merging and assign them afterwords to each section, but the following code throws the exception:
ArrayList footers = new ArrayList();
....
footers.Add(((Document)(m_WordDocsArr[i])).Sections.First.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.FormattedText);
.....
int ih = 0;
foreach (Section sec in ((Document)(m_WordDocsArr[0])).Sections)
{
sec.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].LinkToPrevious = false;
sec.Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary].Range.FormattedText = ((Range)footers[ih]).Duplicate;
ih++;
}
So it is not so trivial for me to merge the documents with their original formatting?????
Please help me !!!???
Thanks.
|
|
|
|
|
Hello (and sorry for my poor english),
I'm beginner with C# and I'm trying to find out how I can give to my C# programm a long text variable as parameter so he could work with and have the result back as a variable.
I really want to give it as parameter, not as file.
(Sorry, but I didn't found what words I must use to find the solution on google)
Thanks for all
|
|
|
|
|
Why dont you use string variable
|
|
|
|
|
Hello and thanks for your answer.
I'm not sure I have explained my problem correctly.
I have a C# programm and I want to pass him text as a variable from an other programm, by example from a Word or Access macro.
Something as :
String strFile = Content of my Word Document (or an XML field of a SQL database or any Formular)
Call CProgramm(strFile)
I want to send to my program the whole text and have back the text modified by my C# programm.
|
|
|
|
|
Send the string as a normal program argument and in your C# program retrieve that from the "string[] args" parameter of the Main method.
Or if your string is very large, write it in a file and send the file path as an argument to your C# program.
|
|
|
|
|
Thanks,
I can reconstruct the args table as following to give me the whole text :
public static void Main(String[] args)
{
String strParameters = "";
for (int intCounter = 0; intCounter < args.Length; intCounter++)
{
strParameters = strParameters + " " + args[intCounter];
}
But the other part of my question is : how can I retrieve the result of my programm as a variable (I don't want to save anything in a file) ?
|
|
|
|
|
Dinglewood wrote: how can I retrieve the result of my programm as a variable (I don't want to save anything in a file) ?
This is not clear. Do you want to get result of another program?
|
|
|
|
|
I apology :
My C# programm make text manipulations with the content of the long text I want to send him.
So I want to send him a long text variable and have the result (the modified content) back.
Hope it is more understable so.
|
|
|
|
|
Dinglewood wrote: I want to send him.
To whom?
I guess you are trying to do inter-process communication. If yes, use WM_COPYDATA[^]. You need to use p-invoke for using this in C#. Check this[^]
|
|
|
|
|
Don't pass entire text documents as an argument. instead write it to a file and pass the path of that file...
Besides, you can pass only "text" as an argument. If you need the byte codes behind the text (bold, italic, tables,...) you'll have difficulty anyway...
|
|
|
|
|
You could pipe it in:
type somefile | myprogram
myprogram then reads it as input.
Or have a TextBox or RichTextBox and paste it in.
|
|
|
|
|
Yeah I'd second that (ignoring the WTF from having what seems to be a word adding piping text around).
You can also capture stdio using Process.* methods.
|
|
|
|
|
how can bind combo box in window application in c# using sql database
damodar singh
ASE in datainfosys limited jaipur
|
|
|
|
|
Use datasource property to set the data. Use DisplayMember to set the field which will be shown to user ans use valuemember to set the field which will represents values.
|
|
|
|
|
you have to know first how to connect to a database.
Search for it, when you get stuck ask here.
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
anyone have links, magazine articles, book titles, or open source project references
what are some algorithms available to simulate how ms word draws each page as i scroll through 1000+ page document. Assuming the whole document cannot be loaded+drawn in memory all at once. How does the buffering work?
Suppose, I create an application that doesn't provide zoom in/out capabilities but i want to show a rectangle with a gradient for grass the size of a football field at a scale 1 to 1.
thanks,
-lm
|
|
|
|
|
You'll probably have better luck in the graphics forum
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
you.suck = (you.Passion != Programming & you.Occupation == jobTitles.Programmer)
1000100 1101111 1100101 1110011 100000 1110100 1101000 1101001 1110011 100000 1101101 1100101 1100001 1101110 100000 1101001 1101101 100000 1100001 100000 1100111 1100101 1100101 1101011 111111
|
|
|
|
|
|
Hello everyone,
Reading the W3 Spec of WS-Addressing is boring. Any recommendations for any easy to read/learn documents/samples?
thanks in advance,
George
|
|
|
|
|
|
Thanks cpkilekofp,
The wiki document is really good. But it is short.
Do you have any documents which is more comprehensive than the wiki document, but more readable than the Spec to recommenda?
regards,
George
|
|
|
|
|
George_George wrote: The wiki document is really good. But it is short.
Do you have any documents which is more comprehensive than the wiki document, but more readable than the Spec to recommenda?
Sadly, at this time I do not. However, I did note that Google produced quite a few documents (the Wikipedia article was simply the first).
|
|
|
|
|
Thanks cpkilekofp,
A further question, in the wikipedia page,
http://en.wikipedia.org/wiki/WS-Addressing
how do you understand "It essentially consists of two parts: a structure for communicating a reference to a Web service endpoint, and a set of Message Addressing Properties which associate addressing information with a particular message."?
1.
My confusion is, what means "a structure for communicating a reference to a
Web service endpoint"?
2.
and what are the so-called "Message Addressing Properties"? Do they mean the
To, Action, ReplyAction headers?
regards,
George
|
|
|
|