Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-11-2025, 03:23 PM
PDanes PDanes is offline Run code in remotely created Word doc Windows 10 Run code in remotely created Word doc Office 2021
Novice
Run code in remotely created Word doc
 
Join Date: Dec 2020
Posts: 12
PDanes is on a distinguished road
Default Run code in remotely created Word doc


I have documents created from a Word template. The template has some bookmarks and formfields, with OnExit calls to a macro. The original machinery was an Excel spreadsheet programmed to create new documents from this template, activated by clicking certain cells in the spreadsheet, then populate the fields from info in the spreadsheet. Recently, the customer decided he wanted QR codes added to the created documents. I've got that done, but it is important that the QR code reflects the contents of the document at all times. Mostly not a problem, OnExit calls attached to each field that the user is allowed to manually update after document creation takes care of that.

But there is one fly in the soup. When the document is first created, I need to update the QR code AFTER Excel finishes filling in the fields, and I haven't been able to figure out how to do that. I put things in the Document Open event, but that gets called as soon as the document is created, BEFORE the fields are filled in, so a QR code generated at that point reflects the then-blank status of the fields. Once the document is finished, any manual change in any field triggers generation of a new QR code, via the OnExit calls, so from then on, it is always current and accurate. But this in-between period is a problem – if the user does not make any further changes after the document is created, the QR code is never 'brought current', and if printed or emailed that way, will be seriously incorrect. And this is usually the case – most of the necessary info is in the spreadsheet, so subsequent manual editing will be the exception rather than the rule.

The only way I have found to make this correct is to add a call in the Excel VBA code to a public routine in the Word template, forcing the QR code generation 'from a distance', so to speak. However, I don't really like that. The spreadsheet is at the customer's place, full of his data, and delivering new code into that is a bit of a pain. I would like to simply send the customer blank new Word templates that will generate QR codes. And they do, except for this.

Is there any way to force Word to run this code AFTER Excel finishes filling in the bookmarked fields? The OnExit code runs when the fields are manually updated, but not when they are updated remotely from code. I haven't found anything that looks like an event I can have automatically fire when fields are updated remotely. I thought about a timer, but that seems a little too shaky – very easy to make the interval too long or too short, and have the results be incorrect again. There doesn't seem to be anything like 'Finished creating' event, or maybe something that would recognize when Excel 'releases' the newly formed document.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
REf Fields show Bookmark whole cell when Bookmark is created by code. pmcpowell Word VBA 2 11-16-2019 07:05 PM
Run code in remotely created Word doc Dimensions of a Table Created in Word 2013 Change when saved in Word 2016 PKW57 Word Tables 2 05-26-2016 05:15 AM
Help: Using Mac remotely from PC based office (Google Docs) sijdavies OneNote 0 05-22-2016 03:10 PM
Run code in remotely created Word doc Linking to remotely stored PDF opens behind joeldodenhoff PowerPoint 1 08-22-2012 12:08 PM

Other Forums: Access Forums

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


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