Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-09-2018, 10:40 PM
kateabode kateabode is offline Auto-populating a document pulling data from external doc using a Userform with Checkboxes Windows 7 64bit Auto-populating a document pulling data from external doc using a Userform with Checkboxes Office 2016
Novice
Auto-populating a document pulling data from external doc using a Userform with Checkboxes
 
Join Date: Sep 2018
Posts: 16
kateabode is on a distinguished road
Default Auto-populating a document pulling data from external doc using a Userform with Checkboxes

I need to make a document for my work. I've been doing my best at finding the answers on the net but just keep coming up against errors and it's just not working.

I have a userform with checkboxes. Multiple checkboxes need to be selected. Basically what I was thinking was...

If A is selected insert data from xyz.doc at bookmark 1

If B is selected insert data from xyz.doc at bookmark 2

Then I also read a post on here about docvariables which i'm not entirely sure about.

The inital code I had was as per below, however I'm it's not working as there's some error with the Else statement however I don't necessarily want the Else statement as I don't want to have one or the other checked, I want to be able to have multiple check boxes checked and pull data from each section in Word (or Excel, whatever you think is best)

Private Sub CommandButton1_Click()

Dim DocSrc As Document, DocTgt As Document, RngSrc As Range, RngTgt As Range

Set DocTgt = ActiveDocument

Set DocSrc = Documents.Open("C:\Users\reception.AIRDG\Documents \Custom Office Templates\2019 Master Specification - Kate.dotm")

Set RngTgt1 = DocTgt.Bookmarks("spec").Range

Set RngTgt2 = DocTgt.Bookmarks("surveys").Range



With ActiveDocument

If CheckBox1.Value = True Then

With DocSrc

Set RngSrc = .Range(.Bookmarks("Demo").Range.Start, .Bookmarks("EndDemo").Range.End)

RngSrc.Copy

With DocTgt



RngTgt1.Paste

Else

If CheckBox2.Value = True Then

With DocSrc

Set RngSrc = .Range(.Bookmarks("Surveys").Range.Start, .Bookmarks("Endsurveys").Range.End)

RngSrc.Copy

With DocTgt

RngTgt2.Paste

End If

.Range.Fields.Update

Application.ScreenUpdating = True

I really hope someone can help me out as I just keep going round and round in circles without really getting anywhere.
Reply With Quote
 

Tags
vba, word-vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Userform with Multiple Cascading Drop Down Lists Populated with External Source Data venganewt Word VBA 21 05-16-2018 02:05 PM
Auto Populating Data with Drop Down Menu vmangano Excel 4 12-20-2016 09:03 AM
Auto-populating a document pulling data from external doc using a Userform with Checkboxes UserForm Dropdown List Not Populating highrise955 Word VBA 14 04-10-2016 12:10 PM
Lack of email addresses auto-populating LarryK Outlook 0 10-10-2012 08:09 AM
Auto-populating a document pulling data from external doc using a Userform with Checkboxes "Auto-populating" data-worksheet to worksheet. meggenm Excel 4 02-04-2012 02:04 AM

Other Forums: Access Forums

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