Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #8  
Old 04-30-2014, 05:30 PM
macropod's Avatar
macropod macropod is offline Update Bookmarks from a Userform Windows 7 32bit Update Bookmarks from a Userform Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by alshcover View Post
How are StrOut variables defined as values in the bookmark code?
You do that by passing the StrOut value to the code you use to update the bookmark.

Since it seems you have multiple bookmarks to update, I've merged this thread and your previous one, so you can see how the two examples we have so far can be made to work with some common bookmark-updating code.

For the two examples so far we could use:
Code:
Private Sub cmdOK_Click()
Application.ScreenUpdating = False
Dim StrOut As String
StrOut = Format(dtDateFiled.Value, "MMMM DD, YYYY ")
Call UpdateBookmark("DateFiled", StrOut)
Select Case cboName.Value
  Case "Bob": StrOut = "1"
  Case "Cindy": StrOut = "2"
  Case "Peter": StrOut = "3"
  Case "Vanessa": StrOut = "4"
End Select
Call UpdateBookmark("Name", StrOut)
Application.ScreenUpdating = True
End Sub
You'll see how we now have two references to 'Call UpdateBookmark', with the bookmark name & content being included as arguments. Those two lines run the following sub, which handles the bookmark updating:
Code:
Sub UpdateBookmark(StrBkMk As String, StrTxt As String)
Dim BkMkRng As Range
With ActiveDocument
  If .Bookmarks.Exists(StrBkMk) Then
    Set BkMkRng = .Bookmarks(StrBkMk).Range
    BkMkRng.Text = StrTxt
    .Bookmarks.Add StrBkMk, BkMkRng
  End If
End With
Set BkMkRng = Nothing
End Sub
Although I've referenced StrOut twice in the cmdOK_Click sub's call to the UpdateBookmark sub, just to show how the same variable can be re-used, the first instance could have been replaced with:
Call UpdateBookmark("DateFiled", Format(dtDateFiled.Value, "MMMM DD, YYYY "))
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

Tags
date, format, userform



Similar Threads
Thread Thread Starter Forum Replies Last Post
Update Bookmarks from a Userform Checkbox in Userform lukael Excel Programming 5 02-18-2014 05:20 AM
Userform Code not quite right - help please vbanovice Word VBA 1 09-29-2013 09:20 PM
Update Bookmarks from a Userform Help with a drop down in userform and variables leemoreau Word VBA 1 09-14-2013 06:01 AM
VBA code to update record in Access 2003 using Userform in Excel primmer3001 Excel Programming 0 08-29-2011 04:25 PM
Update Bookmarks from a Userform Update bookmarks and variables in document webharvest Word VBA 5 06-21-2011 03:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft