473,511 Members | 15,364 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB 6.3/Word 2003 Problem updating specific variables

3 New Member
Hi!

I have a word template that utilizes a userform to gather information from the user and place it into specific Doc Variable locations within the form. If the user reopens the userform and updates the information all of the form fields are reset. My question is: How can I have only the Doc Variable information updated and not the rest of the form fields?

My user form code is as follows:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Sub cmdCancel_Click()
  4.   Unload Me
  5. End Sub
  6.  
  7. Private Sub cmdOK_Click()
  8.   ' Prevent variable from being deleted
  9.   If txtDate = "" Then txtDate = " "
  10.   ActiveDocument.Variables("Date") = txtDate
  11.   If txtClientName = "" Then txtClientName = " "
  12.   ActiveDocument.Variables("Client Name") = txtClientName
  13.   If txtClientIDNumber = "" Then txtClientIDNumber = " "
  14.   ActiveDocument.Variables("Client ID Number") = txtClientIDNumber
  15.   ' Update fields in document
  16.   ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Fields.Update
  17.   ActiveDocument.Fields.Update
  18.   Unload Me
  19. End Sub
  20.  
  21. Private Sub Userform_Initialize()
  22.   ' Load variables into text boxes
  23.   On Error Resume Next
  24.   txtDate = ActiveDocument.Variables("Date")
  25.   txtClientName = ActiveDocument.Variables("Client Name")
  26.   txtClientIDNumber = ActiveDocument.Variables("Client ID Number")
  27. End Sub
I have am new to VBA so any guidence on this would be a big help.

=),
Ducky
Jul 27 '07 #1
1 2157
JustDucky
3 New Member
Oh, I figured out what the code was missing! I have it working now =).

=),

Ducky
Jul 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2996
by: Jaime Rios | last post by:
Hi, I created a COM AddIn for Word that performs the functions that it needs to, but I needed to add the ability for the toolbar created by the COM AddIn to remember it's last position and...
1
7834
by: Bill Agee | last post by:
I want to update a Word template with name, address, etc and save it as a Word document from Microsoft Access. My Word template has the several DOCVARIABLES such as: { DOCVARIABLE...
10
3025
by: Neil | last post by:
An article at http://news.com.com/2100-1012-991694.html?tag=fd_top states: "XML would allow easier interchange of data generated in Office documents with back-end systems or existing Web...
6
2657
by: Ryan Muller | last post by:
My company just upgraded from Access 97 to Access 2003 today and we are having some issues in a database that generates a Word document from information selected in a form. Here is the code we...
14
2913
by: el_sid | last post by:
Our developers have experienced a problem with updating Web References in Visual Studio.NET 2003. Normally, when a web service class (.asmx) is created, updating the Web Reference will...
7
10936
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed...
2
2178
by: jmar | last post by:
I am updating a VB4.0 quote generation program to VB.net. The old program takes user inputs, performs calculations, saves the data to Access databases and uses Crystal Reports 5.0 to generate a...
0
3990
by: funeeldy | last post by:
I need to locate a particular table in a document. I cannot hardcode the table number since it could be different in every doc. I do have some header text that comes right before it consistently,...
0
3729
by: ppardi | last post by:
I'm developing an addin for Word 2007 and I need to determine whether a user saves a Word 2007 document in an older format (97-2003) after a save as is done. The scenario is that the user starts...
0
7242
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7138
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
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
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
7508
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5662
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
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.