Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #31  
Old 01-27-2012, 09:42 PM
macropod's Avatar
macropod macropod is offline Loop through listboxes in Application.OrganizerCopy Windows 7 64bit Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,563
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Marrick,



Try the attached. I've fixed the errant file listing and, I believe, the sorting (that took a while to figure out until I realized it was doing case-sensitive sorts).

I hadn't noticed until just now that you'd posted an update, so the mods aren't based on that (sorry). You'll also notice I've streamlined the code a fair bit, deleting unused/duplicate routines and variable declarations, etc. I even found a couple of unused labels on the form.
Attached Files
File Type: doc Style Copier Application.doc (81.0 KB, 19 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #32  
Old 01-28-2012, 09:19 PM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default Loop through listboxes in Application.OrganizerCopy

Paul,

Thanks so much. I applied your new code while keeping the stuff I added since the previous version and I think I have a good working copy now with all the functionality. The list sorts and everything seems to run well. You didn't need to do the clean up but since you did, thank you again - I really appreciate all your most generous help!

Since the previous version, I added code I found that allows one to resize the form by dragging an icon, something I didn't think was possible for a userform. I incorporated it with other resize functionality I had started, and now you can drag to resize, minimize and maximize almost like a real window. I have another application I'm working on (that formats cross references) for which a true resize would be very helpful, because one would want to toggle between the userform and document often. I have a primitive min-max feature for that application, and I will look into including this new code there to provide more resizing options.

As far as I can tell, aside from some other formatting issues I will deal with, there's one the one snag left with the Style Copier. I have two textboxes that are hidden until the copying starts. One, "txtProcessing", is supposed to show "Processing your request, please wait..." as soon as the copy button is clicked. When the routine finishes, that textbox is supposed to become hidden and another one right below it, "txtCopyStats", is supposed to become visible with an accounting of the number of styles copied to the number of files.

I cannot get the "txtProcessing" to display at all until the copying is finished, at which point it serves no purpose. As I wrote previously:

I have another problem with a msgbox I just added to the Sub CmdCopyStyle_Click module. The intention is to display a textbox reading "Processing..." as soon as the copy routine starts ("Me.txtProcessing.Visible = True"). When I step thru the code, the textbox displays and shuts off at the end when another textbox displays showing the number of styles copied to the number of documents. But during runtime the "Me.txtProcessing.Visible = True" has no effect; if I comment out the statement that shuts it off when the other stats textbox becomes visible, then the txtProcessing textbox displays (so both appear at the same time, but only after the copy code has run).

I even placed a beep just before the "Me.txtProcessing.Visible = True" and it did beep during runtime but still didn't display the textbox. If I place an exit sub right after the statement, the textbox displays (but of course the code stops). So then I tried some code to delay the macro and even put the whole module in another module and ran the display code separately to see if I could "fool" VBA, but nothing worked. I also tried adding if statements, and that didn't do anything.

So there's apparently something about the loop code that prevents the textbox from displaying (but only during runtime). Seems like this is a such a simple thing, but I can't figure out why it doesn't work. Any idea why the txtProcessing doesn't display when it should during runtime?

Latest version (Jan 28) is attached.
Attached Files
File Type: doc Style Copier Application (Jan 28 2012).doc (132.5 KB, 17 views)
Reply With Quote
  #33  
Old 01-29-2012, 03:50 AM
macropod's Avatar
macropod macropod is offline Loop through listboxes in Application.OrganizerCopy Windows 7 64bit Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,563
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Marrick,

With the update in my last post, you don't need either of the SortList1 & SortList2 routines. The SortList(LBox As String) routine replaces all your SortList routines. There were various other code revisions you missed too. I've restored them and added the functionality to get the processing updates to display.

Since you had a limit of 100 files for processing, I've shifted the control code (modified, of course) to the CmdTarget_Click routine and simplified the CmdCopyStyle_Click routine. In order to speed the code up a bit, I've also modified the CmdCopyStyle_Click routine to open the source file. The relevant code is asterisked.

I've also added some commented-out code for opening the destination files. The code runs much faster if they're open, but you'll get a lot of screen flickering and the userform won't be visible for most of the processing time.
Attached Files
File Type: doc Style Copier Application.doc (93.0 KB, 15 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #34  
Old 01-29-2012, 03:50 PM
macropod's Avatar
macropod macropod is offline Loop through listboxes in Application.OrganizerCopy Windows 7 64bit Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,563
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Marrick,

Update attached. You can have your cake and eat it! By starting a temporary Word session and using that to do the processing, the source & destination files can be opened for rapid processing without causing screen flicker and keeping the userform visible.
Attached Files
File Type: doc Style Copier Application.doc (85.0 KB, 96 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #35  
Old 01-29-2012, 05:39 PM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default

Paul,
I was just going to send you a final thank you note for your fixes and solving the real time messaging after fixing up a few formatting items and restoring some label text you removed (and fixing the remove all button, which wasn't removing anything), when I got your latest. I'm all for having my cake and eating it, too, but can you tell me which modules you just changed, so I don't have to compare the code?
Reply With Quote
  #36  
Old 01-29-2012, 05:55 PM
macropod's Avatar
macropod macropod is offline Loop through listboxes in Application.OrganizerCopy Windows 7 64bit Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,563
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Marrick,

In the last update, the only routine that was changed was CmdCopyStyle_Click.

Over the past three posts, though, I've changed bits & pieces in most routines except for the routines relating to the form re-sizing. Some of the changes were as trivial as editing the code indenting and/or deleting unused variables (simply to make it easier to follow what the code was doing - the unused variable and sometimes odd indenting made it harder); others, such as replacing your various SortList1 routines with the SortList(LBox As String) routine and shifting the file limit control code from the CmdCopyStyle_Click routine to the CmdTarget_Click routine were more substantial. I even simplified the UserForm_Initialize and ResetForm routines to eliminate code duplication.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #37  
Old 01-29-2012, 06:34 PM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default

Thanks, Paul. Yes I believe I have incorporated your previous changes and now I've found the new code that opens a separate session (I certainly never would have thought of that, and if I had, I wouldn't have known how to do it!).

Thanks for all your help - you've been wonderful!
Reply With Quote
  #38  
Old 01-30-2012, 08:03 PM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default Loop through listboxes in Application.OrganizerCopy

Paul,

I discovered a small conflict today when I ran Style Copier on my laptop. The copy styles macro produces a file in use message that says WinCalendar.dotm is "locked for editing," even though I didn't open this file. WinCalendar is a calendar add-in for Windows, Word and Excel that I have on both my desktop and laptop. This errors occurs only on the laptop, and does so even after uninstalling WinCalendar there.

It appears that Style Copier does execute the copy, but this error is triggered by your "DoEvents" code that opens a separate Word session. I've attached a screen shot of the message.

Can you figure out why it's conflicting and perhaps modify the DoEvents code to prevent it?
Attached Files
File Type: doc Style Copier-Win Calendar Conflict.doc (55.5 KB, 28 views)
Reply With Quote
  #39  
Old 01-31-2012, 12:54 AM
macropod's Avatar
macropod macropod is offline Loop through listboxes in Application.OrganizerCopy Windows 7 64bit Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,563
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Marrick,

Since I don't have the WinCalendar calendar add-in, I can't really test the conflict to see what's causing it. It may be occuring because source file makes use of the addin.
When you say:
Quote:
this error is triggered by your "DoEvents" code
are you saying that commenting-out the DoEvents code resolves the issue? If so, try leaving it that way and seeing if the code exectute correctly without it. If so, simply delete that line. Alternatively, you may be able to overcome the issue by adding:
wdTmp.DisplayAlerts = wdAlertsNone
after:
wdTmp.Visible = False

The fact that the error continues after uninstalling the application suggests only that the template was left behind after the uninstallation - possibly so that documents that already make use of it would continue to function correctly.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #40  
Old 01-31-2012, 07:52 PM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default

Paul,

The wdTmp.DisplayAlerts = wdAlertsNone had no effect, so i commented out the session code and it ran fine. The only hitch is that the focus shifts to the Word document when the copy routine ends. But that happens only on the laptop. It runs perfectly on the desktop. Laptop has Office 2007; desktop 2010 (same Windows app and version, I think).

I would rather have the focus shift than the WinCalendar message, so I don't think there's any reason to mess with it any further. If you're feeling adventurous, you can always try downloading WinCalendar (www.wincalendar.com/download.html) and see if you can duplicate the message.
Reply With Quote
  #41  
Old 01-31-2012, 09:20 PM
macropod's Avatar
macropod macropod is offline Loop through listboxes in Application.OrganizerCopy Windows 7 64bit Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 20,563
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Hi Marrick,

I'm not sure I want to download & install some software I don't need just for testing. I'm also not sure what you mean by "i commented out the session code".

Unless the WinCalendar addin is affecting destination documents as well, you'll probably get acceptable results if you simply comment-out/delete the line:
wdTmp.Documents.Open FileName:=SourceFile, Visible:=False, AddToRecentFiles:=False 'open the source file

It might also be worth mentioning that opening destination documents for processing means a range of other interruptions could occur. For example, the documents might be password-protected, contain macros of their own, make use of addins, or be designed as mailmerge main documents. All of these could generate pop-ups requiring user input. In that regard, using wdTmp.DisplayAlerts = wdAlertsNone could have adverse consequences for some files (eg mailmerge main documents would lose their data connections and be converted to ordinary documents). I suppose one could develop code that simply closes any such problem files and does the style transfer with them in the closed state. The simpler approach would be to tell the users that, if they get such popups, they'll need to respond appropriately (for a mailmerge main document, that would be 'Yes'). The same applies to your problem source document (if you retain the code to open it).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #42  
Old 01-31-2012, 09:50 PM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default

Paul,

I commented out all the lines starting with "wdTmp.Documents" because of the variable, but that was because I also commented out the variable declaration. I probably could have left that, but I still would have had to comment out most of the code that pertained to the separate Word session.

I recall that at the beginning of this project, I thought I could do all the style copying without opening any files, then discovered I had to open the source. So I did that and closed it as soon as I grabbed its styles (it needed to be opened only to capture its style list, not to copy them). The styles can be copied to the dest files without opening them. So I didn't think much about the possible problems of opening files.

I created Style Copier primarily out of a need I saw for copying styles to multiple files, which the Organizer cannot do, and secondarily to get around Organizer's template defaults. The need for copying to multiple arose out of a client I was working for who had tons of existing documents which made no use of styles, but many of them did use multilevel (outline) numbering. That numbering almost always goes awry unless it is set up in a list style or similar style. I configured those styles in a non-template and used that to copy to other documents; there was no need for a template since I wasn't creating new documents. I'm not working there anymore but thought other technical writers might find Style Copier useful, but since I'm not in touch with any of them anymore, there probably won't be any users! But at least I will have this utility if I ever run into a similar scenario again.

Again, thank you for all your help - I couldn't have finished it without you!
Reply With Quote
  #43  
Old 10-12-2020, 10:50 AM
Charles Kenyon Charles Kenyon is offline Loop through listboxes in Application.OrganizerCopy Windows 10 Loop through listboxes in Application.OrganizerCopy Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 6,996
Charles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to beholdCharles Kenyon is a splendid one to behold
Default

Paul, I saved your document as a .dotm so that it can be used as a Global Template.
I added a QAT button which, in my system shows up at the end of the QAT.
If this is inappropriate, please feel free to delete this post.
Attached Files
File Type: dotm Style Copier Application.dotm (92.5 KB, 5 views)
Reply With Quote
  #44  
Old 10-12-2020, 11:07 AM
Marrick13 Marrick13 is offline Loop through listboxes in Application.OrganizerCopy Windows XP Loop through listboxes in Application.OrganizerCopy Office 2010 32bit
Advanced Beginner
Loop through listboxes in Application.OrganizerCopy
 
Join Date: Jun 2006
Posts: 92
Marrick13 will become famous soon enough
Default

No problem, thanks. Those two minimize and maximize buttons in the upper right should probably be removed as I've since foound code that [performs those functions properly, without those jerry-rigged methods. Live and learn...
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use for loop in formula in VBA? tinfanide Excel Programming 1 12-06-2011 08:33 AM
music loop in powerpoint presentation genoMU69 PowerPoint 1 06-15-2011 08:00 AM
While loop not working right Cbrehm Excel Programming 0 05-11-2011 11:05 AM
Loop through listboxes in Application.OrganizerCopy Continuous Loop cksm4 Word 6 01-06-2011 09:03 PM
Outlook 2003 restart in a loop Stegel Outlook 0 06-29-2007 12:34 PM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 02:19 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft