|
-
Feb 17th, 2005, 10:47 AM
#1
Thread Starter
New Member
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!
-
Feb 17th, 2005, 11:03 AM
#2
Re: Linking word with VB....
Try adding this to your code
VB Code:
oWord.ActiveDocument.SaveAs FileName:="c:\x.doc"
-
Feb 18th, 2005, 10:44 AM
#3
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|