Results 1 to 3 of 3

Thread: Linking word with VB....

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    5

    Linking word with VB....

    Hello

    Right now i am sending data from vb to excel in these steps.

    1. opening an exisitng excel template
    2. filling in data with vb
    3. saving it with a name thro vb
    4. opening the saved application and automatically displaying it to the user

    This is the code i used.......

    fname = "c"\sample.xls"
    Set xlsApp = New excel.Application
    xlsApp.DisplayAlerts = False
    xlsApp.Visible = False
    xlsApp.ScreenUpdating = False
    xlsApp.Workbooks.Open FileName:=App.Path + "\TEMPLATES\ENQUIRY.XLT"
    xlsApp.Worksheets("Sheet1").Select
    xlsApp.Range("A25").Value ="blah blah"
    ----------------------
    ---------------------
    ------------------

    xlsApp.ActiveWorkbook.Close Savechanges:=True, FileName:=FNAME
    xlsApp.Quit
    Set xlsApp = Nothing
    Set xlsapp1 = New excel.Application
    xlsapp1.Workbooks.Open FNAME
    xlsapp1.Application.Visible = True
    End Sub

    Now i want to do the same thing with Word.

    1. I am able to open an existing template (.dot)
    2. i am able to fill in data using vb
    3. This step is a problem...i am not able to save it with a name thro vb..i dunno how
    4. i am able to open it for display

    Can sm1 help me out with this 3rd step ????

    this is the code i used

    Set oword = New Word.Application
    oword.Application.Documents.Add "C:\tEMPLATES\sale.dot", False, wdNewBlankDocument
    oword.Visible = True
    oword.Activate
    oword.Application.ActiveDocument.Bookmarks("saleorderno").Range.InsertAfter "hi"
    -------------
    --------------
    Set oword = Nothing


    PLease.......i have learnt a lot frm this forum.......hope i learn this too

    Thanks a million time s!

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Linking word with VB....

    Try adding this to your code
    VB Code:
    1. oWord.ActiveDocument.SaveAs FileName:="c:\x.doc"

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2004
    Posts
    5

    Re: Linking word with VB....

    Thanks a lot

    It works !!!

    can u refer me any book/online lib where i can get more info about microsoft word 9.0 linking with vb ?

    thanks anyway !!!!

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