First thanks for your response.
In my form load, i am loading the ole unbound control like this :
Private Sub Form_Load()
Dim wrdApp As Object
Set wrdApp = CreateObject("Word.Application")
With Me![olePreviewLetter]
.Enabled = True
.Locked = False
' Specify what kind of object can appear in the field.
.OLETypeAllowed = acOLEEmbedded
' Class statement for Word document.
.Class = "Word.Document"
' Specify the file to be embedded.
' Type the correct path name.
.SourceDoc = "C:\mlprog\TempLetter.DOC"
' Create the embedded object.
.Action = acOLECreateEmbed
' Optional size adjustment.
.SizeMode = acOLESizeZoom
End With
wrdApp.Application.Quit
Set wrdApp = Nothing
End Sub
When i double click the ocntrol, it gets activated and opens a Winword.exe process, and i will edit the docuemnt and when i click the File button,
If blnWordAppOpened = True Then
' blnLetterUpdated = True
' On Error Resume Next
Dim NewObject As Object
' Dim wrdApp As Object
' Set wrdApp = CreateObject("Word.Application")
' Dim wrdApp1 As Object
' Set wrdApp1 = GetObject("C:\mlprog\TempLetter.DOC", "Word.Application")
sLetterPath = "C:\mlprog\TempLetter1.DOC"
sLetter = "TempLetter1"
' Copies the embedded object to Clipboard.
' Me!olePreviewLetter.Verb = 0
' Me!olePreviewLetter.Action = 7 ' Activates the application
Me!olePreviewLetter.Object.Application.WordBasic.EditSelectAll
Me!olePreviewLetter.Object.Application.WordBasic.EditCopy
Me!olePreviewLetter.Action = 9 'Close the OLE object
Me!olePreviewLetter.Action = 10 ' Delete the OLE Object
DoEvents
'' ' Creates a new document and pastes Clipboard contents.
'' ' Saves the document in the Word directory and closes the
'' ' document.
'' Set NewObject = CreateObject("Word.Basic")
'' NewObject.FileNew
'' NewObject.EditPaste
'' NewObject.FileSaveAs NewDoc
'' NewObject.FileClose
'' NewObject.Appclose
'' NewObject.Application.Quit
''
'' Frees the memory used by the objects.
'' Set NewObject = Nothing
' Open the generated Letter to preserve the formatting and pastes Clipboard contents.
' Saves to a new file and closes the document
Set NewObject = CreateObject("Word.Application")
NewObject.Visible = False
'NewObject.Activate
NewObject.Documents.Open FileName:="C:\mlprog\Template.doc"
NewObject.Selection.WholeStory
NewObject.Selection.Paste
'removes an extra space!
NewObject.Selection.TypeBackspace
' NewObject.ActiveDocument.SaveAs filename:="C:\mlprog\TempLetter1.DOC"
NewObject.ActiveDocument.SaveAs sLetterPath
NewObject.ActiveDocument.Close
NewObject.Application.Quit
' Frees the memory used by the objects.
Set NewObject = Nothing
' wrdApp.Application.Quit
' Set wrdApp = Nothing
' wrdApp1.Application.Quit
' Set wrdApp1 = Nothing
' oWord.Application.Quit
' Set oWord = Nothing
Else
sLetterPath = "C:\mlprog\TempLetter.DOC"
sLetter = "TempLetter"
End If
That WINWORD,EXE is still running and not closes, this happens only in word 2007.
Please guide me how to solve this issue.
Thanks
Harish