VBA & Word Automation

D

Doctorjones_md

I have a Word document (Proposal Template) that needs to be modified based
on the Items/Services sold/offered to the customer. What is the best way to
accomplish this?

The Items/Services offered are listed in a Word Table in a separate
document.

Example:

Firewall
Description Details Monthly Setup
Firewall
Not Included
NA
NA

Firewall
Cisco PIX 501-10

· 10 IPs, 10 Mbps, 7500 Concurrent Connections

· Stateful packet inspection and intrusion protection

· Fully Managed Device, includes 24x7 Monitoring, Rule Changes and
1 Hour Replacement Guarantee
$xxx
$xxx


Firewall
Cisco PIX 506E

· 40 Mbps, 25000 Concurrent Connections

· Stateful packet inspection and intrusion protection

· Fully Managed Device, includes 24x7 Monitoring, Rule Changes and
1 Hour Replacement Guarantee
$xxx
$xxx



Ideally, what I'd like to be able to do is: Provide Option (Radio) Buttons
where the Sales Rep can click store the Rows to be Cut and Pasted into the
Proposal Template.

I considered Bookmards, but I'm not certain that bookmarks will give me
what I need (since the entry spans several columns in a table). What are my
options?

Thanks in advance.
 
D

Doug Robbins - Word MVP

You could have each of the items in a template with each one contained
within a bookmark. Then you could have a userform with a checkbox against
each item on the userform and then code behind a command button on the form
that deleted the bookmark ranges for the items that were not checked.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Doctorjones_md

Doug,

Thank you for the quick reply -- I'm having some difficulty getting
bookmarks to span 3-4 cells in a table -- is this possible?

For example, if I have a Word Table with "Description" "Details"
"Monthly Fee" "Setup Fee" as column headers, is it possible to create a
bookmark for the entire Row (spanning 4 columns)? I'm relatively new with
VBA -- could you provide me with a starting point (including some sample
code) from which to build on?

Much thanks in advance.
 
D

Doug Robbins - Word MVP

It would probably best to have a bookmark for each cell, but you may be able
to use

ActiveDocument.Bookmarks("bookmarkname").Range.Cells(1).Range

to refer to the first cell in the bookmark, then increment the number for
the remaining cells.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

doctorjones_md

Doug -- sorry for the delay in my reply -- I've been spending some time
trying to see if I could make some headway on this project ...

Here's what I'm working with:

I have a Word.dot template with (1) form (frmMain)

1. The code on the Word.dot is:

Option Explicit

Private Sub Document_New()
frmMain.Show
End Sub
==================================
2. The code on frmMain is: (****See explanatory Notes****)

Option Explicit

Private Sub cmdCancel_Click()
Unload Me
ActiveDocument.Close SaveChanges:=False
End Sub

'initialize form
Private Sub frmMain_Initialize()

txtCompany.Value = Null
txtProject.Value = Null
txtAddress1.Value = Null
txtAddress2.Value = Null
txtCity.Value = Null
txtState.Value = Null
txtZip.Value = Null
txtName.Value = Null
txtTitle.Value = Null
txtPhone.Value = Null
txtMobile.Value = Null
txtEmail.Value = Null
txtStateFull.Value = Null
cbxProcurement.Value = Null

End Sub

'set document population variables from userform input
Private Sub cmdOK_Click()

Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("CompanyCover").Range.Text = txtCompany.Value
.Bookmarks("ProjectCover").Range.Text = txtProject.Value
.Bookmarks("CompanySow").Range.Text = txtCompany.Value
.Bookmarks("ProjectSow").Range.Text = txtProject.Value
.Bookmarks("Address1Sow").Range.Text = txtAddress1.Value
.Bookmarks("Address2Sow").Range.Text = txtAddress2.Value
.Bookmarks("CitySow").Range.Text = txtCity.Value
.Bookmarks("StateSow").Range.Text = txtState.Value
.Bookmarks("ZipSow").Range.Text = txtZip.Value
.Bookmarks("NameSow").Range.Text = txtName.Value
.Bookmarks("PhoneSow").Range.Text = txtPhone.Value
.Bookmarks("MobileSow").Range.Text = txtMobile.Value
.Bookmarks("EmailSow").Range.Text = txtEmail.Value

End With

'Insert Procurement Ts & Cs (****This simply inserts the contes of an
entire file into the Active Document -- I need to be able to discriminate
between which rows in a table to insert into the Active Document****)

Dim sFilePath As String
If cbxProcurement = True Then
ActiveDocument.Bookmarks("Procurement").Select
sFilePath = ActiveDocument.AttachedTemplate.Path & "\Shane.doc"
Selection.InsertFile sFilePath, , False, False
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.TablesOfContents(1).Update

'End Insert Procurement T's & C's

'These are the bookmarks on the page to be inserted into
coverpage/Proposal

Application.ScreenUpdating = False
With ActiveDocument
.Bookmarks("CompanyProc").Range.Text = txtCompany.Value
.Bookmarks("StateFullProc").Range.Text = txtStateFull.Value
.Bookmarks("Address1Proc").Range.Text = txtAddress1.Value
.Bookmarks("Address2Proc").Range.Text = txtAddress2.Value
.Bookmarks("CityProc").Range.Text = txtCity.Value
.Bookmarks("StateProc").Range.Text = txtState.Value
.Bookmarks("ZipProc").Range.Text = txtZip.Value
.Bookmarks("CompanyProc2").Range.Text = txtCompany.Value
.Bookmarks("Address1Proc2").Range.Text = txtAddress1.Value
.Bookmarks("Address2Proc2").Range.Text = txtAddress2.Value
.Bookmarks("CityProc2").Range.Text = txtCity.Value
.Bookmarks("StateProc2").Range.Text = txtState.Value
.Bookmarks("ZipProc2").Range.Text = txtZip.Value
.Bookmarks("CompanyProc3").Range.Text = txtCompany.Value

End With

End If

Application.ScreenUpdating = True

Unload Me

End Sub
====================
EXPLANATORY NOTES: The above codes works, but what I need for it to do is
this --

I've added several additional forms (accessed from frmMain) which have
checkboxes and radio buttons fo the user makes his or her selections. The
the data in the corresponding bookmarks should then be inserted into the
Word.dot when the OK button is clicked. Here are my questions:

1. I need for the SUBMIT button on frmMain to be disabled until the user
makes at least (1) selection from the subordinate forms -- what is the best
way to achieve this?

2. I need for these (10) forms to insert the corresponding bookmarks into a
Table (1) principal Word.dot -- What I did in the Word.dot was to take your
advice and bookmark the entire row (spanning 4 columns) -- I'm lost on how
to incorporate your code
(ActiveDocument.Bookmarks("bookmarkname").Range.Cells(1).Range).

I'm kinda wrapped around the axle here -- Could you give me an idea what I
need to do to incorportate this functionality -- for example:

Just a simple list of components needed ...

Word.dot - with sample code
A couple of forms showing code to allow for selected checkboxes/radio
buttons to populate bookmarks in the Word.dot (active document)

Much Thanks In Advance

Shane
 
D

Doctorjones_md

Doug (or anyone else who might have an idea),

Just wondering if this code might get me to where I need to be (in using
checkboxes/radio buttons on a series of forms to populate bookmarks in a
table on my Active Document -- SOF.dot:

Bookmark, Replace Text of a Bookmark in document2 With the Text of a
Bookmark in document1:
Note that both documents must be open when the macro is run.
Documents("c:\temp\document2.doc").Bookmarks("doc2BookmarkName").Range.Text
= _
Documents("c:\temp\document1.doc").Bookmarks("doc1BookmarkName").Range.Text
Alternate Code:
Documents("c:\temp\document2.doc").Bookmarks(1).Range.Text = _
Documents("c:\temp\document1.doc").Bookmarks(4).Range.Text
where the text of the 4th bookmark in document1 is replacing the text of the
1st bookmark in document2.

Thanks in advance for your assistance in pointing me in the right direction

Shane
===========================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top