HI, Im using this code to COPY from my app. so the user can PASTE Later somewhere (excel, word..).
But after copy to clipboard and quit word object it fires "do you want to save unsaved file?"
How can i close the document using an object like this??
Displayalerts=false is not working.
This is the code:
----------------------------------------------------------------------------
Code:Private Sub CopyGrid() On Error GoTo ErrorHand: Dim objWord As Object 'instead of Word.Application Dim objDoc As Object 'instead of Word.Document Dim strData As String If objWord Is Nothing Then Set objWord = CreateObject("Word.Application") Else Set objWord = GetObject(, "Word.Application") End If DoEvents With MSFlexGrid1 .Row = 0 .Col = 1 .RowSel = .Rows - 2 .ColSel = .Cols - 1 strData = .Clip End With 'The Clip property separates Rows with a carriage return. These 'need to be converted to Tabs as well in order to create the Word Table properly. strData = Replace(strData, vbCr, vbTab) Clipboard.Clear Clipboard.SetText strData 'saco las alertas de word 'Create the Word Table by pasting the Grid Text into a document 'and then use the ConvertToTable method Set objWord = New Word.Application Set objDoc = objWord.Documents.Add objDoc.Range.Paste objDoc.Range.ConvertToTable wdSeparateByTabs, MSFlexGrid1.Rows - 2, MSFlexGrid1.Cols - 1 'Copy the Word Table to the Clipboard. The user can then Paste 'the table into their word documents. objDoc.Range.Copy objWord.DisplayAlerts = False '----------------------- quit word -------------------------- If Not (wd Is Nothing) Then Set wd = Nothing If Not (objWord Is Nothing) Then objWord.Application.Quit If Not (objWord Is Nothing) Then Set objWord = Nothing '------------------------------------------------------------ ErrorHand: Resume Next End Sub




Reply With Quote