473,405 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

mailmerged document by using automation from VB.NET to OFFICE 2000

Hi,

I have developed a vb.net application to create a mail-merged
document by
using Automation to word from VB.NET.
I added the following reference to the application:
Microsoft Office 10.0 Object Library

In runtime, when I click that button, I open a word doc. I create a
commandbar whith in that commandbar a combobox with a list of fields
to mailmerge.
When I select any value from the combobox,that value is added as
mailmerge field and is displayed on the word doc

This works perfect in Office XP but in Office 2000 you can't select a
field out of the list.

This is my code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim d1 As Word.Document
Dim dtcol As DataColumn
WordApp.Visible = True
WordApp.WindowState = Word.WdWindowState.wdWindowStateMaximize
d1 = WordApp.Documents.Open(FileName:=Application.Start upPath
& "\test.doc", Visible:=True)
d1.Activate()
Dim fld
Dim cbar1 As Office.CommandBar
Dim myControl As Office.CommandBarComboBox
cbar1 = d1.CommandBars.Add(Name:="Velden",
Position:=Office.MsoBarPosition.msoBarFloating, Temporary:=True)
cbar1.Visible = True
myControl = cbar1.Controls.Add(Type:=Office.MsoControlType.mso ControlComboBox)

For Each dtcol In
lijstpersonen.oDataTable.DefaultView.Table.Columns
myControl.AddItem(dtcol.ColumnName)
Next
myControl.DropDownLines = 10
myControl.DropDownWidth = 150
myControl.ListHeaderCount = 0
ctlComboBoxHandler.SyncBox(myControl, d1)
End Sub
End Class
'Following class to handle change event of combobox of commandbar in
worddocument
Public Class ComboBoxHandler
Private d As Word.Document
Private WithEvents ComboBoxEvent As Office.CommandBarComboBox
Public Sub SyncBox(ByVal box As Office.CommandBarComboBox, ByVal
d1 As Word.Document)
ComboBoxEvent = box
d = d1
End Sub
Private Sub ComboBoxEvent_Change(ByVal Ctrl As
Office.CommandBarComboBox) Handles ComboBoxEvent.Change
Dim a As Word.Selection
a = d.ActiveWindow.Selection

d.MailMerge.Fields.Add(a.Range, Ctrl.Text)
a = Nothing
End Sub

Another problem I have is when I open the document the first time, it
works perfectly. I close it again, and then I open it for a second
time, I get a message that the RPC-server is not avalailable.

Can somebody help me with these two problems?

Thanx

Karel
Nov 20 '05 #1
0 1341

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Emily John | last post by:
I have a word document that I need to send it as an attachment to an XML file. Basically, converting into byte array or using some encoding mechanism. This has to be done through XML serialization...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
3
by: Leah | last post by:
I'm updating an app currently in Access 2000, which uses Outlook 2000 (sr1a) to send emails behind the scenes. Several issues have come up since I've started work on this. This office is moving...
1
by: Sandeep | last post by:
Hi, I am trying for word 2000 automation with c#. There I want to get all custom document property of the document as follows: Microsoft.Office.Core.DocumentProperties props =...
5
by: John Smith | last post by:
Hey folks, I'm creating an MS Word document in a C# Windows application. Because the client base has so many different versions of Word they are using, I opted to go with late binding to create...
2
by: Claus - Arcolutions | last post by:
I got a word document as a stream, and I want to get the text from the word document. But I cant seem to find anything to use for that purpose. The "Microsoft office ?.object" com reference, only...
7
by: Tosch | last post by:
Has anyone ever tried to save a Excel document and a Word document in the same physical file? I have an application where there is always 1 Excel and 2 Word documents and 1 or 2 other files that...
3
by: Tim Marsden | last post by:
Hi, I am currently creating an instance of Excel using VB.NET Automation. dim xl as Excel.Application xl = new Excel.Application However, how can I have more control over the starting of...
5
by: ruomingxu via AccessMonster.com | last post by:
I am new in this area. I want to use values in a Access database and pass them to a word document. I tried this test code in a form of the Access database but it didn't work (temp.doc is a word...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.