Results 1 to 3 of 3

Thread: Opening a word doc in word

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2000
    Posts
    70

    Question

    how do you open a word doc in ms word from VB?
    Daniel Rose
    VB 5.0 Enterprise.
    irc:irc2.dynam.ac

    If TheCodeInTheSig() Is Not Lame() Then IDontKnowWhatIs()

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    This is the way we do it when we want to manipulate the data in the document, put some values in a table, create a table, do a Find and replace, text formatting absolutely anyting you can do yourself in word manually you can code here.

    Code:
    Dim objWordApp As Word.Application
    Dim objDoc As Word.Document
    
        Set objWordApp = CreateObject("Word.Application")
    '  turn off autorecover save
        objWordApp.Options.SaveInterval = 0               
    '  turn off prompt for saving to normal template
        objWordApp.Options.SaveNormalPrompt = False       
        objWordApp.Options.SavePropertiesPrompt = False       
    
        '  make word visible for development purposes or invisible to the users
        objWordApp.Visible = True
        objWordApp.WindowState = wdWindowStateNormal
         
        With objWordApp
            .Documents.Open App.Path & "\DDTemplate.doc", False, True, False, , , True
            Set objDoc = .Documents(.ActiveDocument.Name)
        End With
    
        With objDoc
            .BuiltInDocumentProperties(wdPropertyTitle) = strTable
            .BuiltInDocumentProperties(wdPropertySubject) = txtTableDesc.Text
            .Fields.Update
        End With
        
        '...
        ' 
        ' do some stuff here
        ' anything to manipulate the document contents
        '...
    
            
        objDoc.PrintOut False, , wdPrintAllDocument, , , , , Copies:=CInt(txtCopies)
        objDoc.Close SaveChanges:=wdDoNotSaveChanges
        objWordApp.Quit
        Set objWordApp = Nothing


    Things I do when I am bored: DotNetable

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