Hussain Saffar

How to Create an Actionb Button in MS Word Using VSTO

This Action should read fax number send as a fax

Anyone can help me or give me a hint to this please




Re: Visual Studio Tools for Office Create Action Button

Maarten van Stam

Wow, that's like asking to write you a program...

Provide some more information on what you have (developing environment, OS, Office products) and what you try to accomplish with your application. Then tell us what you tried and where you failed to go on.

Please remember that this forum is intended to solve specific VSTO issues and questions, and that the forum most likely is not suitable to provide support to step by step build a complete solution. Therefore make sure you break down your questions into 'black box' scenarios where forum readers can respond to.

-= Maarten =-






Re: Visual Studio Tools for Office Create Action Button

Hussain Saffar

I need some to tell i generated 5 pages (Mail Merge) i can email each page seperatly




Re: Visual Studio Tools for Office Create Action Button

Cindy Meister

Leaving aside the fact that you should be able to mail merge directly to fax, if fax software is installed...

I'm not sure mail merge is really the most efficient method for doing this, if you're using VSTO, but I can give you a general outlines for possible approaches:

1. The information is in the merge result. You can't use bookmarks because these are lost during mail merge. But you can format the information with a unique style. Or place some kind of text "markers" around it. Whatever you decide to use, locate the entry (Range.Find is usually good). Extract the information.

2. The fax information is surely in the data source used for the mail merge. Connect to the database and extract it.

3. Least efficient would be to use the DataSource property of the main merge document. Set the ActiveRecord to the first, then loop through the records, extracting the information from the appropriate field.

To send the individual faxes:

A mail merge to letter results in a single document; a section break (of type "New Page") has been inserted between each record. So you can loop through a document's sections to pick up each fax. Transfer the range of the section to a new document, and send that as the fax. To transfer the range of a section to a new document, use something along these lines:

Dim docFax as Word.Document = wdApp.Documents.Add()

docFax.Content.FormattedText = docMergeResult.Sections(index).Range.FormattedText

Note that this is just a rough outline. The actual solution will need quite a bit of testing and tweaking to get exactly the result you'll be looking for.






Re: Visual Studio Tools for Office Create Action Button

Hussain Saffar

Cindy Meister,

thank you for your reply.

that was really cool information . How can i loop thruogh a document with "New page" as a new section. could you help me in this part please






Re: Visual Studio Tools for Office Create Action Button

Cindy Meister

Hi Hussain

Roughly like this. doc is a variable typed Word.Document, to which the merge result has been assigned. wdApp represents the Word.Application (substitute however you're doing it). I'm assuming VB.NET, since you haven't indicated otherwise:

Dim sec as Word.Section

Dim docFax as Word.Document

For each sec in doc.Sections

If sec.PageSetup.SectionStart = Word.WdSectionStart.wdSectionNewPage Then

docFax = wdApp.Documents.Add() 'If you need a certain page layout, specify a template name

docFax.Content.FormattedText = sec.Range.FormattedText

End If

Next






Re: Visual Studio Tools for Office Create Action Button

Hussain Saffar

Cindy Meister ,

thanks again....

let me explain my scenario ....

I do have one word document contains 20 pages. on each page we will have a fax number.

what im trying to do is to email seaparate page based on the Fax number. For Example,

Page 1

---------------------------------------------------------

Fax:+2222222

tel:+11111111

name:hussain

ssssssssssssssss

sssssssssssssss

ssssssssssssss

-------------------------------------------------------

then i sould email it as including the other infromaion in the Body

:+2222222@fax.doaminname.com

the same will go to the other pages

is this possible






Re: Visual Studio Tools for Office Create Action Button

Cindy Meister

Hussain Saffar wrote:

Cindy Meister ,

thanks again....

let me explain my scenario ....

I do have one word document contains 20 pages. on each page we will have a fax number.

what im trying to do is to email seaparate page based on the Fax number. For Example,

Page 1

---------------------------------------------------------

Fax:+2222222

tel:+11111111

name:hussain

ssssssssssssssss

sssssssssssssss

ssssssssssssss

-------------------------------------------------------

then i sould email it as including the other infromaion in the Body

:+2222222@fax.doaminname.com

the same will go to the other pages

is this possible

I refer you back to my first reply, where I outlined three possible approaches for getting the fax number...

However, if you're actually sending this as email, why not merge to email Set up your data source to include the entire email address as one of the fields. That will save you a lot of work...