Results 1 to 2 of 2

Thread: OLE & Process ID

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Vienna
    Posts
    24

    OLE & Process ID

    Hi!

    I have an ole object. In this object I have a word document. When I want to save this document with "ole1.object.saveas .."
    he open a process "WINWORD.EXE". However, when it is done, it doesn't close the process. Does anybody know how I can close this process ?

    Thanks a lot!

    Thomas

  2. #2
    jim mcnamara
    Guest
    ole1.object.quit - I think is the method you want. Note the red line of code.


    Here is a sample use of .SaveAs from www.vb2themax.com

    Code:
    ' Convert a Word-compatible format to an other format.
    ' Parameters:
    '  - sFileName is the file to convert
    '  - wdFormat is the destination file's format
    '  - sNewFileName is the destination file. If not specified the the routine 
    ' will use the sFileName's path & name
    '
    ' NOTE: requires the Microsoft Word type library
    '
    ' Example: convert from DOC to HTML
    '   ConvertWordDocument("C:\Documents\MyWordFile.doc", wdFormatHTML)
    
    Function ConvertWordDocument(ByVal sFilename As String, _
        Optional ByVal wdFormat As WdSaveFormat = wdFormatText, _
        Optional ByVal sNewFileName As String) As Boolean
        Dim iPointer As MousePointerConstants
        Dim sExtension As String
        Dim oWord As New Word.Application
    
        On Error GoTo ErrHandler
        iPointer = Screen.MousePointer
        
        ' open the file
        oWord.Documents.Open sFilename, False, False, False, , , , , , _
            wdOpenFormatAuto
        
        ' the destination filename if sFileName is sNewFileName is missing
        If Len(sNewFileName) = 0 Then
            sNewFileName = sFilename
            ' remove the actual extension ad add the one specified by sExtension
            If InStr(sNewFileName, ".") > 0 Then sNewFileName = Left$(sNewFileName, _
                InStr(sNewFileName, ".") - 1)
            ' set the extension for the selected destination format
            sExtension = Switch(wdFormat = wdFormatDocument, ".doc", _
                wdFormat = wdFormatDOSText, ".txt", _
                wdFormat = wdFormatDOSTextLineBreaks, ".txt", _
                wdFormat = wdFormatEncodedText, ".txt", wdFormat = wdFormatHTML, _
                ".htm", wdFormat = wdFormatRTF, ".rtf", wdFormat = wdFormatTemplate, _
                ".doc", wdFormat = wdFormatText, ".dot", _
                wdFormat = wdFormatTextLineBreaks, ".txt", _
                wdFormat = wdFormatUnicodeText, ".txt")
            ' add the extension to the file name
            sFilename = sFilename & sExtension
        End If
        
        ' save the file
        oWord.ActiveDocument.SaveAs sNewFileName, wdFormat, , , False
        
        ' close Word
        oWord.Quit
        Set oWord = Nothing
    
        ConvertWordDocument = True
        
    ErrHandler:
        ' restore the original mouse pointer
        Screen.MousePointer = iPointer
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width