Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

User Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tripla - 30 Mar 2007 05:57 GMT
I have created a user form for a letter template and would like the
senders information to stay the same if saved  (kind of like
personalizing the template), unless cleared.  My problem is coding the
form to keep the senders information intact upon opening.  I have this
as my code wondering if I should go about this differently:
Public Sub cmdClose_Click()
   Application.ScreenUpdating = False
   With ActiveDocument
       .Bookmarks("To").Range.Text = txtTo.Value
       .Bookmarks("Attn").Range.Text = txtAttn.Value
       .Bookmarks("Faxto").Range.Text = txtFaxto.Value
       .Bookmarks("Phoneto").Range.Text = txtPhoneto.Value
       .Bookmarks("From").Range.Text = txtFrom.Value
       .Bookmarks("Faxfrom").Range.Text = txtFaxfrom.Value
       .Bookmarks("Phonefrom").Range.Text = txtPhonefrom.Value
       .Bookmarks("Date").Range.Text = txtDate.Value
       .Bookmarks("Notes").Range.Text = txtNotes.Value
       .Bookmarks("Pages").Range.Text = txtPages.Value
   End With
   Application.ScreenUpdating = True
   Unload Me
End Sub

Any help is appreciated
Thanks
Tripla
Jonathan West - 30 Mar 2007 10:47 GMT
>I have created a user form for a letter template and would like the
> senders information to stay the same if saved  (kind of like
[quoted text clipped - 18 lines]
>    Unload Me
> End Sub

Hi Tripla

When opening the form, you want to do the reverse assignment

   With ActiveDocument
       txtTo.Value =.Bookmarks("To").Range.Text

etc.

This populates the userform with the current contents of the bookmarks. Put
this code into the UserForm_Initialize event.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Rob - 30 Mar 2007 13:24 GMT
In this office we have a lot of forms that do something similar except the
data is never stored in the templates because new docs are always created
from them. I have to save user data like their fax and extension, etc, to
populate forms for them. To do this I use System.PrivateProfileString in the
initialize to store and get stuff from their registry. Just thought I'd
mention that as an option.
Doug Robbins - Word MVP - 30 Mar 2007 20:12 GMT
In the Initialize event of your userform, include the command

txtFrom.Text = Application.UserName

Signature

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

>I have created a user form for a letter template and would like the
> senders information to stay the same if saved  (kind of like
[quoted text clipped - 22 lines]
> Thanks
> Tripla

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.