473,769 Members | 5,570 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim d1 As Word.Document
Dim dtcol As DataColumn
WordApp.Visible = True
WordApp.WindowS tate = Word.WdWindowSt ate.wdWindowSta teMaximize
d1 = WordApp.Documen ts.Open(FileNam e:=Application. StartupPath
& "\test.doc" , Visible:=True)
d1.Activate()
Dim fld
Dim cbar1 As Office.CommandB ar
Dim myControl As Office.CommandB arComboBox
cbar1 = d1.CommandBars. Add(Name:="Veld en",
Position:=Offic e.MsoBarPositio n.msoBarFloatin g, Temporary:=True )
cbar1.Visible = True
myControl = cbar1.Controls. Add(Type:=Offic e.MsoControlTyp e.msoControlCom boBox)

For Each dtcol In
lijstpersonen.o DataTable.Defau ltView.Table.Co lumns
myControl.AddIt em(dtcol.Column Name)
Next
myControl.DropD ownLines = 10
myControl.DropD ownWidth = 150
myControl.ListH eaderCount = 0
ctlComboBoxHand ler.SyncBox(myC ontrol, 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.CommandB arComboBox
Public Sub SyncBox(ByVal box As Office.CommandB arComboBox, ByVal
d1 As Word.Document)
ComboBoxEvent = box
d = d1
End Sub
Private Sub ComboBoxEvent_C hange(ByVal Ctrl As
Office.CommandB arComboBox) Handles ComboBoxEvent.C hange
Dim a As Word.Selection
a = d.ActiveWindow. Selection

d.MailMerge.Fie lds.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 1359

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

Similar topics

3
2781
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 in c#. Is it possible to do it through xml serialization ? THanks, --Emily *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
12
5530
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 and office XP components installed. ie I have word/access/excel 2k/xp/2003 installed. I tried to do a usual access 2k to word 2k automation yet I get the error "Automation Error" "ClassFactory cannot supply requested class" when on late binding try...
3
1943
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 to Office 2003, and the annoying security prompts for Outlook automation are not wanted by the customer. So, I started looking at CDO mail. Lots of stuff there, but nothing works - in Access 2000. (Known bug, alternative is to use outlook...
1
2324
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 = (Microsoft.Office.Core.DocumentProperties)aDoc.CustomDocumentProperties; (where aDoc is active Word document). But this gives me an Invalid Cast Exception. I feel like using the correct syntax. Pls help.
5
6695
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 the document. **Everything works great, but I can't figure out how to do 2 things: 1) Double Spacing 2) Insert a Page Break
2
3188
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 include functionality to read from a file (as far as I know). I looked a little on the structure of the document, but it doesnt seem to have any common structures, especially not if you compare from different office versions.
7
4880
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 belong together. I want to save them in 1 physical file so the users can't mix them up. Any ideas? Tosch
3
5068
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 Excel. For example I want to specify command line switches, or prevent certain ComAdd-ins from loading when I start Excel.
5
6516
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 doc already stored in C: drive): Dim oX As Object Set oX = CreateObject("C:\temp.doc") oX.editreplace "<<FirstName>>", "Richard", 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0 oX.Application.Visible = True Set oX = Nothing
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9998
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.