Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-08-2012, 03:07 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default How to I make text Bold in a User Form -Visual Basic

Hello,



I have created a Macro enabled template with User form that automatically opens when the document is opened. One of the issues I am having is trying to figure out how to have the text in a field come out to the document in Bold format.

Does anyone know how to do this? I have attached a screenshot

Thanks
Attached Images
File Type: jpg screenshot.jpg (103.6 KB, 26 views)
Reply With Quote
  #2  
Old 03-09-2012, 05:05 PM
macropod's Avatar
macropod macropod is offline How to I make text Bold in a User Form -Visual Basic Windows 7 64bit How to I make text Bold in a User Form -Visual Basic Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

Hi gurp,

If you want the text on the userform to appear bold, set the font attribute for that element to bold. For example:
TextBox1.Font.Bold = True

If you want the output in the document to be bolded, set a range object to the destination, populate the range, then format the range as bold. For example:
Code:
Dim Rng As Range
Set Rng = ActiveDocument.Bookmarks("SomeBookmark").Range
With Rng
  .Text = TextBox1.Text
  .Font.Bold = True
End With
ActiveDocument.Bookmarks.Add "SomeBookmark", Rng
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 03-12-2012, 01:58 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default

This is the error i get
what am i doing wrong?
Attached Images
File Type: jpg a.jpg (23.8 KB, 29 views)
Reply With Quote
  #4  
Old 03-12-2012, 02:25 PM
macropod's Avatar
macropod macropod is offline How to I make text Bold in a User Form -Visual Basic Windows 7 64bit How to I make text Bold in a User Form -Visual Basic Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

That doesn't show an error, which would be indicated by yellow highlighting and an error message, but a breakpoint.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 03-12-2012, 02:29 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default

picture attached
Attached Images
File Type: jpg e.jpg (100.8 KB, 26 views)
Reply With Quote
  #6  
Old 03-12-2012, 02:51 PM
macropod's Avatar
macropod macropod is offline How to I make text Bold in a User Form -Visual Basic Windows 7 64bit How to I make text Bold in a User Form -Visual Basic Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

And what is the error message you're getting?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 03-12-2012, 02:59 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default

Run-Time error '424

Object required
Reply With Quote
  #8  
Old 03-12-2012, 03:35 PM
macropod's Avatar
macropod macropod is offline How to I make text Bold in a User Form -Visual Basic Windows 7 64bit How to I make text Bold in a User Form -Visual Basic Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

I am unable to replicate that error with the kind of code I gave you. See attached. It would seem there is something somewhere else in your project that is having an adverse effect.
Attached Files
File Type: zip UserFormDemo.zip (21.4 KB, 27 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 03-12-2012, 03:39 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default

I am a novice user to VBA. With the code you supplied, what needs to be changed? just the text in red?

Dim Rng As Range
Set Rng = ActiveDocument.Bookmarks("SomeBookmark").Range
With Rng
.Text = TextBox1.Text
.Font.Bold = True
End With
ActiveDocument.Bookmarks.Add "SomeBookmark", Rng
Reply With Quote
  #10  
Old 03-12-2012, 03:57 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default

Here is the link to the file:
Reply With Quote
  #11  
Old 03-12-2012, 03:58 PM
macropod's Avatar
macropod macropod is offline How to I make text Bold in a User Form -Visual Basic Windows 7 64bit How to I make text Bold in a User Form -Visual Basic Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
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

From looking at your images, you'd also have to change the 'textbox1' reference. The first one had that change, but for some reason you undid that change before posting the second image.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 03-12-2012, 04:05 PM
gurp99 gurp99 is offline How to I make text Bold in a User Form -Visual Basic Windows Vista How to I make text Bold in a User Form -Visual Basic Office 2007
Novice
How to I make text Bold in a User Form -Visual Basic
 
Join Date: Apr 2010
Posts: 18
gurp99 is on a distinguished road
Default

SOLVED

I got it to work...

Thank you very much for the help Paul.

Much obliged

Last edited by gurp99; 03-12-2012 at 04:07 PM. Reason: Solved
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word Visual Basic error - run time error 504 crazymorton Word 11 01-13-2012 04:32 AM
Visual Basic Editor changes from 2003 to 2007 Rockitman31 Word VBA 4 09-21-2011 12:01 PM
How to I make text Bold in a User Form -Visual Basic Basic user needs drop down menus Mabozar Word 1 01-19-2010 02:49 PM
Referencing Tables in Visual Basic Editor DavidB Word Tables 0 09-21-2009 04:01 PM
How to I make text Bold in a User Form -Visual Basic A little Visual Basic Help Please leroytrolley Excel 4 08-22-2008 03:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:06 AM.


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