Userform check boxes to enter text from word file
I have created a user form to enter data into a word document.
What I am now trying to add is the option to add different paragraphs to the letter based on whether the check boxes are ticked.
What I would like is to be able to have is 5 different paragraphs saved as word/text files (so they can be easily edited if needed).
There would then be 5 check boxes to select which are entered
into the letter.
Any ideas?
I managed to get a similar result for an option button where the text was all entered in the code but these paragraphs are longer and would be more straightforward to have them as separate files.
Thanks
Keys to the Problem Userform check boxes to enter text from word file
If you use the following in your userform code, the building block/autotext entry 'paymentdue' will be inserted at the 'test' bookmark.
Private Sub CommandButton1_Click()
Dim oRng As Range
Dim strTemplate As String
strTemplate = ThisDocument.AttachedTemplate
If CheckBox1.Value = True Then
Set oRng = ActiveDocument.Bookmarks("test").Range
InsertMyBuildingBlock "paymentdue", oRng
End If
Unload Me
End Sub
Sub InsertMyBuildingBlock(ByRef strBBName As String, oRng As Range)
Dim oTemplate As Template
Dim oAddin As AddIn
Dim lngIndex As Long
'Ignore the attached template for now if the document is based on the normal template '?????????
'Look in and insert from attached template if other than Normal.dotm.
If ActiveDocument.AttachedTemplate <> NormalTemplate Then
Set oTemplate = ActiveDocument.AttachedTemplate
'Check each building block entry in the attached template
For lngIndex = 1 To oTemplate.BuildingBlockEntries.Count
'Look for the building block name and if found, insert it.
If oTemplate.BuildingBlockEntries(lngIndex).Name = strBBName Then
oTemplate.BuildingBlockEntries(strBBName).Insert Where:=oRng
GoTo lbl_Exit
End If
Next lngIndex
End If
'The entry has not been found. Look and insert from add-ins.
For Each oAddin In AddIns
'Check currently loaded add-ins.
'If oAddin.Installed = False Then Exit For 'Wouldn't you then fail to check any other loaded add-in?
If oAddin.Installed = False Then GoTo NextAddin
Set oTemplate = Templates(oAddin.Path & Application.PathSeparator & oAddin.Name)
'Check each building block entry in the each add in
For lngIndex = 1 To oTemplate.BuildingBlockEntries.Count
If oTemplate.BuildingBlockEntries(lngIndex).Name = strBBName Then
'Look for the building block name and if found, insert it.
oTemplate.BuildingBlockEntries(strBBName).Insert Where:=oRng
GoTo lbl_Exit
End If
Next lngIndex
NextAddin:
Next oAddin
'The entry has not been found.
Look and insert from Normal.dotm
Set oTemplate = NormalTemplate
For lngIndex = 1 To oTemplate.BuildingBlockEntries.Count
If oTemplate.BuildingBlockEntries(lngIndex).Name = strBBName Then
oTemplate.BuildingBlockEntries(strBBName).Insert Where:=oRng
GoTo lbl_Exit
End If
Next lngIndex
'If the entry has not been found. Look and insert from Building Blocks.dotx template
Templates.LoadBuildingBlocks
For Each oTemplate In Templates
If oTemplate.Name = "Building Blocks.dotx" Then Exit For
Next
For lngIndex = 1 To Templates(oTemplate.FullName).BuildingBlockEntries.Count
If Templates(oTemplate.FullName).BuildingBlockEntries(lngIndex).Name = strBBName Then
Templates(oTemplate.FullName).BuildingBlockEntries(strBBName).Insert Where:=oRng
GoTo lbl_Exit
End If
Next lngIndex
'If the entry has still not been found finally check the Built-In Building Blocks.dotx template
For Each oTemplate In Templates
If oTemplate.Name = "Built-In Building Blocks.dotx" Then Exit For
Next
For lngIndex = 1 To Templates(oTemplate.FullName).BuildingBlockEntries.Count
If Templates(oTemplate.FullName).BuildingBlockEntries(lngIndex).Name = strBBName Then
Templates(oTemplate.FullName).BuildingBlockEntries(strBBName).Insert Where:=oRng
GoTo lbl_Exit
End If
Next lngIndex
'All sources have been checked and the entry is still not found
MsgBox "Entry not found", vbInformation, "Building Block " & Chr(145) & strBBName & Chr(146)
lbl_Exit:
Set oTemplate = Nothing
Exit Sub
End Sub
Check memory problems
Memory management issues can also cause a BSOD in Windows 7. Thankfully, Windows 7 has a Memory Management Diagnostic tool that detects and solves problems related to system memory.
- Click on the Start button on the Taskbar.
- Type "Windows Memory Diagnostic Tool" or "Memory" (without quotes) in the Search box or,
- Click on Windows Memory Diagnostic Tool (in the search results).
- Click on "Restart now and check for problems (Recommended)".
- The system will restart, and you need to follow the instructions given on the screen.
Recommended Method to Repair the Problem: Userform check boxes to enter text from word file:
How to Fix Userform check boxes to enter text from word file with SmartPCFixer?
1. Download Error Fixer. Install it on your computer.
2. After the scan is done, you can see the errors and problems which need to be repaired.
3. The Repair part is done, the speed of your computer will be much higher than before and the errors have been removed. You can also use other functions in this software. Like dll downloading, junk file cleaning and print spooler error repair.
Related: accelerometerst exe hp download Icsetup ExeComputer Error Svchost Exe Svchost Exe System Error ERROR CANNOT EXECUTE FILE IN TRANSACTION Free Ntoskrnl Exe For Windows7 Download Explorer Exe Error On Shut Down Windows Search Exe Bad Image Hphmon exe Msnnm exe InboxTool Scanpst Exe ntoskrnl exe bsod keygen exe updater exe Odometer exe firefox exe entry point not found Sqlmangr exe Download Regtlib exe unwise exe Driver For Hpoipm07 exe Wmp54gv4 exe Download sndvol exe,Blue Screen error BCCode d1 Windows 7 64 bit Pro realtek hd audio drivers High memory usage on Windows Explorer realtek hd audio driver Is there a way to have pages be normal size ie cover the entire screen when viewing on Windows 7 realtek sound drivers Right Click Libraries Windows explorer has stopped working realtek drivers windows 7 Start Menu Windows Explorer has Stopped Working Realtek Audio Drivers Windows XP Windows 7 Professional cannot find my External Drive realtek high definition audio driver Windows won t maximize from task bar and won t show preview realtek high definition audio driver nVidia Graphics Driver Version V9.18.13.3349 , 379.77 MBytes
Read More: [Solved] Where do I download Powershell v2 for Windows 7?,[Anwsered] Windows 7 backup size shows 2.27 GB, even though I deleted all of the backups.,Troubleshoot:msn won't allow me to share webcam (samsung n120) Error,Fast Solution to Error: External 3.5\" Floppy Drive -'Disks Are Not Formatted' Message,Network Key help,why its says expe win 32 application not valid,why can't I go to another computer to see my msn portfolio,What is ESENT, and what do I do about this ESENT Error occurring once on Win7(64)SP1?:,I made XMAS address labels last year and now I just want to have the addresses on the labels wiith no clip art. How do I do it without retyping 4 pages of addresses?
No comments:
Post a Comment