zaharius Posted August 31, 2012 Posted August 31, 2012 I make project with reference to Microsoft Word Object Library, Form1 (eazy windows form), Dialog1 (dialog form). In Form1 I insert Button1 and Button2. The code: Code: Imports Microsoft.Office.Interop Public Class Form1 Private WithEvents wdApp As New Word.Application Private WithEvents wdDoc As New Word.Document Private txtBox As New TextBox Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dialog1.Controls.Add(txtBox) �make textbox programmatically txtBox.Visible = True End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dialog1.ShowDialog() �call dialog from windows form � textbox is visible End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click wdDoc = wdApp.Documents.Add wdDoc.ActiveWindow.Visible = True End Sub Private Sub wdApp_WindowBeforeRightClick(ByVal Sel As Microsoft.Office.Interop.Word.Selection, ByRef Cancel As Boolean) Handles wdApp.WindowBeforeRightClick Cancel = True Dialog1.ShowDialog() �call dialog from Word events � textbox is unvisible End Sub End Class I press Button2, right-click in Word-document and see loaded Dialog1 without textbox! Haw call ShowDialog from Word event procedure and show programmatically created controls? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.