Hi all,

I tried to open the document using the below code, well its not opening, and its not showing the value in the variable oDoc

 oDoc = oWord.Documents.Open(FileName, False)
this is the code where its not showing the value and its not putting in to the Panel control i.e pnlWordContainer

Ok i am adding a very short code, i mean i have modified it, and please tell me why is it not taking the value... How to make it to take the value...

i have 2 panels on my form
2-pnlWordContainer - on this i have to show the .docx document....

Imports Microsoft.Office.Interop

Imports Microsoft.Office.Interop.Word
Imports VB = Microsoft.VisualBasic
'Imports BTIS.TList
Imports System.Drawing
Imports System.Diagnostics
Imports System.Data
Imports System.Windows.Forms.Application

Public Class Word_doc_Export

 Public Const SWP_FRAMECHANGED As Integer = &H20
    Public Const SWP_NOACTIVATE As Integer = &H10
    Public Const SWP_DRAWFRAME As Integer = &H20
    Public Const SWP_NOMOVE As Integer = &H2
    Public Const SWP_NOSIZE As Integer = &H1
    Public Const SWP_NOZORDER As Integer = &H4
    Public Const SWP_SHOWWINDOW As Integer = &H40
    Public Const SWP_NOSENDCHANGING As Integer = &H400

    Public Const SMTO_ABORTIFHUNG As Int32 = &H2

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
    Private Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal bRepaint As Integer) As Integer

    Private WithEvents oWord As Word.Application
    Private WithEvents oDoc As Word.Document

    Dim WordHandle As Integer

 Private Sub Word_doc_Export_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        oWord = New Word.Application
            End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sv As New FarPoint.Win.Spread.SheetView
        Dim chkbox As New FarPoint.Win.Spread.CellType.CheckBoxCellType
        Dim FileNameWithoutPath As String
        FileName = " C:\Users\aseema\Desktop\RA code of my understanding1.docx"

        ' On Error GoTo LoadError
        Loading = True
        FileNameWithoutPath = System.IO.Path.GetFileName(FileName)

        grd.Visible = False
        Panel1.Dock = DockStyle.Fill
        pnlWordContainer.Dock = DockStyle.Fill
        pnlWordContainer.Visible = False

        'Black Magic
        oWord = New Word.Application
        oDoc = New Word.Document

        oWord.Caption = "SIM"
        WordHandle = FindWindow("Opusapp", "SIM")
        SetParent(WordHandle, Me.pnlWordContainer.Handle.ToInt32)
        oWord.Caption = Nothing

        WordVersion = CheckMSWordVersion()

        oDoc = oWord.Documents.Open(FileName, False) 'Here the Word Documet is opened..
        oDoc.Application.Visible = True
        oDoc.Application.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone

        oWord.Options.WarnBeforeSavingPrintingSendingMarkup = False


    End Sub

End Class
Where is my code going wrong? why is it so....
Also i dnt know about the handlers... so i m googling abt them now, but mean while if you get to know help me out.

Will be waiting for your reply

Kind Regards