Exemplo n.º 1
0
        // Open a file (the file must exists) and activate it
        public void Open(string strFileName)
        {
            object fileName  = strFileName;
            object readOnly  = false;
            object isVisible = true;

            ODoc = OWordApplic.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);

            ODoc.Activate();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 附加dot模版文件
        /// </summary>
        private void LoadDotFile(string strDotFile)
        {
            if (!string.IsNullOrEmpty(strDotFile))
            {
                Word.Document wDot = null;
                if (OWordApplic != null)
                {
                    ODoc = OWordApplic.ActiveDocument;

                    OWordApplic.Selection.WholeStory();

                    //string strContent = oWordApplic.Selection.Text;

                    OWordApplic.Selection.Copy();
                    wDot = CreateWordDocument(strDotFile, true);

                    object bkmC = "Content";

                    if (OWordApplic.ActiveDocument.Bookmarks.Exists("Content") == true)
                    {
                        OWordApplic.ActiveDocument.Bookmarks.get_Item
                            (ref bkmC).Select();
                    }

                    //对标签"Content"进行填充
                    //直接写入内容不能识别表格什么的
                    //oWordApplic.Selection.TypeText(strContent);
                    OWordApplic.Selection.Paste();
                    OWordApplic.Selection.WholeStory();
                    OWordApplic.Selection.Copy();
                    wDot.Close(ref missing, ref missing, ref missing);

                    ODoc.Activate();
                    OWordApplic.Selection.Paste();
                }
            }
        }
Exemplo n.º 3
0
        // Open a new document
        public void Open()
        {
            ODoc = OWordApplic.Documents.Add(ref missing, ref missing, ref missing, ref missing);

            ODoc.Activate();
        }