Hi,

First I am beginner in C#.

1-But I need to know how to use wor automation and save the new file in other location then print it when need, that was first.

2-I also need to know how to play a specific video from a path using Microsoft.Directx.AudioVideoPlayBack library.

Hint

Question no. 2 i know the code but there is problem with compatibility because I use Visual Studio 2010, How can I solve this problem?.

Notice

I can't change the virsion of visual studio.

Thanks.

Welcome fawi.


>But I need to know how to use wor automation and save the new file in other location then print it when need, that was first.

I guess! you are about Word Automation.

>I also need to know how to play a specific video from a path using Microsoft.Directx.AudioVideoPlayBack library.

Use SilverLight/WPF

Thanks very much it was very helpful,but in word automation i still don't know how to print it later.I have code that make me edit the "dot files" and print it in the same instance, but what i need is to call this file later and print it and save in another location.

//this code to edit the word file and save it
//after saving it in aspecific location i need to open it just as review not to edit
//or printing it through printing button
private void CreateWordDocument(object fileName, 
                                        object saveAs)
        {
            //Set Missing Value parameter - used to represent
            // a missing value when calling methods through
            // interop.
            object missing = System.Reflection.Missing.Value;

            //Setup the Word.Application class.
            Word.Application wordApp = 
                new Word.ApplicationClass();

            //Setup our Word.Document class we'll use.
            Word.Document aDoc = null;

            // Check to see that file exists
            if (File.Exists((string)fileName))
            {
                DateTime today = DateTime.Now;

                object readOnly = false;
                object isVisible = false;

                //Set Word to be not visible.
                wordApp.Visible = false;

                //Open the word document
                aDoc = wordApp.Documents.Open(ref fileName, ref missing, 
                    ref readOnly, 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);

                // Activate the document
                aDoc.Activate();

                // Find Place Holders and Replace them with Values.
                this.FindAndReplace(wordApp, "<name>", "Zach Smith");
                this.FindAndReplace(wordApp, "<address>", "00 Main Street");
                this.FindAndReplace(wordApp, "<city>", "Louisville");
                this.FindAndReplace(wordApp, "<state>", "KY");
                this.FindAndReplace(wordApp, "<zip>", "40202");
                this.FindAndReplace(wordApp, "<company>", "TechRepublic");

                //Example of writing to the start of a document.
                aDoc.Content.InsertBefore("This is at the beginning\r\n\r\n");

                //Example of writing to the end of a document.
                aDoc.Content.InsertAfter("\r\n\r\nThis is at the end");
            }
            else
            {
                MessageBox.Show("File dose not exist.");
                return;
            }

            //Save the document as the correct file name.
            aDoc.SaveAs(ref saveAs, ref missing, ref missing, ref missing, 
                    ref missing, ref missing, ref missing, ref missing, 
                    ref missing, ref missing, ref missing, ref missing, 
                    ref missing, ref missing, ref missing, ref missing);

            //Close the document - you have to do this.
            aDoc.Close(ref missing, ref missing, ref missing);
            

            MessageBox.Show("File created.");
        }

        /// <summary>
        /// This is simply a helper method to find/replace 
        /// text.
        /// </summary>
        /// <param name="WordApp">Word Application to use</param>
        /// <param name="findText">Text to find</param>
        /// <param name="replaceWithText">Replacement text</param>
        private void FindAndReplace(Word.Application WordApp, 
                                    object findText, 
                                    object replaceWithText)
        {
            object matchCase = true;
            object matchWholeWord = true;
            object matchWildCards = false;
            object matchSoundsLike = false;
            object nmatchAllWordForms = false;
            object forward = true;
            object format = false;
            object matchKashida = false;
            object matchDiacritics = false;
            object matchAlefHamza = false;
            object matchControl = false;
            object read_only = false;
            object visible = true;
            object replace = 2;
            object wrap = 1;

            WordApp.Selection.Find.Execute(ref findText,
                ref matchCase, ref matchWholeWord,
                ref matchWildCards, ref matchSoundsLike,
                ref nmatchAllWordForms, ref forward,
                ref wrap, ref format, ref replaceWithText,
                ref replace, ref matchKashida,
                ref matchDiacritics, ref matchAlefHamza, 
                ref matchControl);
        }

        private void btnCreateDocument_Click(object sender, EventArgs e)
        {
            CreateWordDocument(@"C:\temp\test.doc",
                                @"C:\temp\new.doc");
        }
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.