Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-13-2016, 05:13 AM
Jow Jow is offline Insert more than 500 characters on FormField Word by VBA Windows 7 32bit Insert more than 500 characters on FormField Word by VBA Office 2010 32bit
Novice
Insert more than 500 characters on FormField Word by VBA
 
Join Date: Sep 2016
Posts: 3
Jow is on a distinguished road
Default Insert more than 500 characters on FormField Word by VBA

Hi!
How can i insert a FormField on Word whit more than 500 characters, by VBA? I'm trying by code below, but it's inserting only the first 255 characters an the lasts 255 characters, but my complete text has around 900 characters, its inserting my text cuting..

If Len(FillText) > 255 Then
SecondBit = Right(FillText, 256)
.FormFields("fldIndeferidos").Result = FirstBit
.Unprotect
.Bookmarks("fldIndeferidos").Range.InsertAfter SecondBit


.Protect Type:=wdAllowOnlyFormFields, NoReset:=True
Else
ActiveDocument.FormFields("fldIndeferidos").Result = FillText
End If

...i have tryed change the code to create ThirdBit for more than 510 characteres, but i had not success..

Thanks
Reply With Quote
  #2  
Old 09-13-2016, 02:49 PM
macropod's Avatar
macropod macropod is offline Insert more than 500 characters on FormField Word by VBA Windows 7 64bit Insert more than 500 characters on FormField Word by VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

You can use code like:
Code:
ActiveDocument.Bookmarks("Name").Range.Fields(1).Result.Text = String$(1000, "A")
to populate a formfield with a string of any length. Simply replace 'Name' with the formfield's internal bookmark name and 'String$(1000, "A")' with your actual string.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 09-14-2016, 05:49 AM
Jow Jow is offline Insert more than 500 characters on FormField Word by VBA Windows 7 32bit Insert more than 500 characters on FormField Word by VBA Office 2010 32bit
Novice
Insert more than 500 characters on FormField Word by VBA
 
Join Date: Sep 2016
Posts: 3
Jow is on a distinguished road
Default

Thanks, i was using the wrong method. Now it worked.
Reply With Quote
  #4  
Old 09-14-2016, 04:59 PM
macropod's Avatar
macropod macropod is offline Insert more than 500 characters on FormField Word by VBA Windows 7 64bit Insert more than 500 characters on FormField Word by VBA Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
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

It's not that you were necessarily using the 'wrong' method, but that directly writing to a formfield's result (e.g. Activedocument.FormFields(1).Result = "A") only handles up to 255 characters.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 09-15-2016, 04:06 AM
Jow Jow is offline Insert more than 500 characters on FormField Word by VBA Windows 7 32bit Insert more than 500 characters on FormField Word by VBA Office 2010 32bit
Novice
Insert more than 500 characters on FormField Word by VBA
 
Join Date: Sep 2016
Posts: 3
Jow is on a distinguished road
Default

Thanks, for help me!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert more than 500 characters on FormField Word by VBA How to insert paragraph character after every 500 characters? aditya_bokade Word VBA 28 11-13-2021 10:48 PM
Macro to insert WordArt characters Jennifer Murphy Word VBA 1 02-25-2014 03:10 AM
Insert more than 500 characters on FormField Word by VBA Formfield calculation Joachim Word 4 03-08-2013 01:56 AM
Junk characters (box-like characters) in Word file Sashikala Word 1 04-20-2010 02:03 PM
Auto populate formfield from dropdown menu jmofstead Word 0 02-26-2010 10:35 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:35 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