Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #12  
Old 09-11-2020, 05:10 PM
Guessed's Avatar
Guessed Guessed is offline Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Windows 10 Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

In terms of principles, if your Excel data is contained in a single sheet but you need to grab information from it right through your code then you should only grab it once and store that either in memory or write it to somewhere in the Word doc so that the Excel workbook connection can be closed again. You don't want to keep reconnecting or hold the connection open while other stuff goes on if you can avoid it.

Your code is amalgamating the tabular data from Excel into strings using commas "," as a delimiter which will then enable you to examine the string and work out which column supplied the substring. This will fail spectacularly if strings appear in the source data. For this reason, it is better to use a character as your delimiter that WILL NEVER appear in the source data. For this purpose I tend to use "|" but anything will do. The rows are then separated by carriage returns which should be OK as long as there are none in your Excel source.

Then finally your code ends with a disabled line which would have written the gathered data to a userform control. Without this, as soon as the code finishes, the information gathered is lost and you will need to revisit Excel to get it back again. You could alternatively write it to other places but there isn't code there for that.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
word fields, word vba, word vba macro



Similar Threads
Thread Thread Starter Forum Replies Last Post
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Reset "Button" to clear Word user-filled form, from all filled details. Rafi Word VBA 20 01-20-2023 02:16 PM
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled VBA to Populate text content controls in word from excel lmoir87 Word VBA 15 05-27-2022 04:22 PM
Auto populate form (data from excel) in Word based on drop down list selection (data from excel) wvlls Word VBA 1 03-22-2019 02:29 PM
Form with content controls - expands but at the bottom of the form louiseword Word 3 05-27-2016 12:47 AM
Word form that auto-populates (from Excel sheet) other content controls based on one,manually filled Date auto-populates based on checkbox mcarter9000 Word VBA 5 12-23-2010 12:39 PM

Other Forums: Access Forums

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