Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2010, 08:51 PM
crazymorton's Avatar
crazymorton crazymorton is offline Word Visual Basic error - run time error 504 Windows 7 Word Visual Basic error - run time error 504 Office 2007
Novice
Word Visual Basic error - run time error 504
 
Join Date: Nov 2010
Posts: 8
crazymorton is on a distinguished road
Default Word Visual Basic error - run time error 504

Hi all,
We have a program called MasterPack (old school dos style) which we generate quotes from and this picks up a quote.doc in a folder called Quotes in the C drive which is a mail merge document and populates all the fields. There are 3 files in this Quotes folder, quote.doc, QUOTE.txt, and quote.hed

Recently one of my employees had his PC upgraded to a new unit and it came with Office 2007 (previously used 2003) and now we have this run time error.

So what happens now is we go through the steps and then it gets to the "Opening this document will run the following SQL command" and click Yes to continue, the SQL msg comes up again (that never happened before) so we click yes again. It thinks then opens the word doc and populates the fields but then the run time error window pops up and if we choose "End" the merge fields are not populated and return to the merge field names EG. <<CustName>> etc etc.
if we choose debug we get the VB window with this section highlighted in yellow WordBasic.Activate "Quote.doc"
Then we close that and lose all data again.
I am assuming it's something to do with 2007 and compatibility with the old quote.doc template being in 2003.

can anyone confirm this and offer a simple solution or do i need to rewrite the quote.doc in Word 2007. I would like to keep it in 2003 for compatibility reasons, which reminds me when 2007 opens the template it does say "Compatibility mode"
clear as mud right?



thanks
Reply With Quote
  #2  
Old 11-22-2010, 04:18 AM
Kimberly Kimberly is offline Word Visual Basic error - run time error 504 Windows 7 Word Visual Basic error - run time error 504 Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Posts: 517
Kimberly is on a distinguished road
Default

WordBasic is from Word 95. You just need to find the equivalent in VBA.
Try replacing WordBasic.Activate "Quote.doc"
with
Windows("Quote.doc").Activate
Reply With Quote
  #3  
Old 11-22-2010, 05:04 AM
crazymorton's Avatar
crazymorton crazymorton is offline Word Visual Basic error - run time error 504 Windows 7 Word Visual Basic error - run time error 504 Office 2007
Novice
Word Visual Basic error - run time error 504
 
Join Date: Nov 2010
Posts: 8
crazymorton is on a distinguished road
Default

ok thanks I'll give that a go and report back.
cheers
Reply With Quote
  #4  
Old 11-22-2010, 08:16 PM
crazymorton's Avatar
crazymorton crazymorton is offline Word Visual Basic error - run time error 504 Windows 7 Word Visual Basic error - run time error 504 Office 2007
Novice
Word Visual Basic error - run time error 504
 
Join Date: Nov 2010
Posts: 8
crazymorton is on a distinguished road
Default

hi...I'm not sure if I'm doing something wrong but that change wouldn't stick. it stayed highlighted yellow, which i assume means it's still an error?
This is driving us mad, I guess we shold redo the template in 2007?
Reply With Quote
  #5  
Old 03-17-2011, 11:58 AM
almac16 almac16 is offline Word Visual Basic error - run time error 504 Windows XP Word Visual Basic error - run time error 504 Office 2007
Novice
 
Join Date: Mar 2011
Posts: 1
almac16 is on a distinguished road
Default

Quote:
Originally Posted by crazymorton View Post
hi...I'm not sure if I'm doing something wrong but that change wouldn't stick. it stayed highlighted yellow, which i assume means it's still an error?
This is driving us mad, I guess we shold redo the template in 2007?
Hey there.... did you ever figure this out? I am having the exact same problem on my system. I'd appreciate any feedback you have on how you resolved this issue.

Thanks,
Alex.
Reply With Quote
  #6  
Old 03-17-2011, 03:59 PM
crazymorton's Avatar
crazymorton crazymorton is offline Word Visual Basic error - run time error 504 Windows 7 Word Visual Basic error - run time error 504 Office 2007
Novice
Word Visual Basic error - run time error 504
 
Join Date: Nov 2010
Posts: 8
crazymorton is on a distinguished road
Default

Hi Alex,
no unfortunately. still a major hassle
Reply With Quote
  #7  
Old 03-20-2011, 04:18 AM
macropod's Avatar
macropod macropod is offline Word Visual Basic error - run time error 504 Windows 7 32bit Word Visual Basic error - run time error 504 Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,249
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

Can either of you post the sub containing the offending code? It would be easier to diagnose that way. If the sub references any external variables, please include those too.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 06-19-2011, 04:02 PM
Matt Sharpe Matt Sharpe is offline Word Visual Basic error - run time error 504 Windows XP Word Visual Basic error - run time error 504 Office 2007
Novice
 
Join Date: Jun 2011
Posts: 2
Matt Sharpe is on a distinguished road
Default

Quote:
Originally Posted by crazymorton View Post
Hi all,
We have a program called MasterPack (old school dos style) which we
The problem is caused by Word 2007/2010 renaming the window to "quote.doc [Compatibility Mode]"

Masterpack creates a DDE script that tries to activate the window named "quote.doc", but it does not exist, so it fails.

The solution is to modify the program QUOTE.WORD.MERGE in Masterpack so that the call to TU.DDE.EXEC.MACRO looks for the window named "quote.doc [Compatibility Mode]"

A better solution would be if Office would NOT RENAME WINDOWS unexpectedly! But I would guess that's not going to happen any time soon.

If anyone else in your organisation is using Word 97 or Word 2003, it will be necessary to come up with a more intelligent solution to allow for the original "quote.doc" window name to be activated.

Regards,

Matt.
Reply With Quote
  #9  
Old 06-19-2011, 04:43 PM
macropod's Avatar
macropod macropod is offline Word Visual Basic error - run time error 504 Windows 7 64bit Word Visual Basic error - run time error 504 Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,249
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 Matt,

Whilst it might be true in one sense that the "problem is caused by Word 2007/2010 renaming the window", the underlying cause is that MasterPack was poorly programmed so as to rely on the window name instead of relying on the document name. Your suggestion, to:
Quote:
modify "the program QUOTE.WORD.MERGE in Masterpack so that the call to TU.DDE.EXEC.MACRO looks for the window named "quote.doc [Compatibility Mode]"
might work around the problem for now, but can't be relied on for the future. For example, if you later decide you need to modify the code so that it creates a new document in the docx format, the 'Compatability Mode' workaround will start causing problems. Likewise if MS decides to change the display in a later version/update. The only 100% reliable cure is to set a variable name for the 'Quote' document and use that as the parameter by which all calls to the document are processed.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 06-19-2011, 05:53 PM
Matt Sharpe Matt Sharpe is offline Word Visual Basic error - run time error 504 Windows XP Word Visual Basic error - run time error 504 Office 2007
Novice
 
Join Date: Jun 2011
Posts: 2
Matt Sharpe is on a distinguished road
Default

True enough, mine is a quick solution, not an elegant one. I'm a Unix programmer not a Windows/Office programmer, and don't have much DDE experience - I would guess that you could probably use SBXA's TU.DDE.READ function to return the window name associated with the document, and then make that window active? Or can you make a window active with a direct macro call referencing the document name?

To be fair on the original programmer of QUOTE.WORD.MERGE, he or she did write it in March 1999 and probably never considered the possibility of a "compatibility mode"!
Reply With Quote
  #11  
Old 06-20-2011, 12:26 AM
macropod's Avatar
macropod macropod is offline Word Visual Basic error - run time error 504 Windows 7 64bit Word Visual Basic error - run time error 504 Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,249
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 Matt,

If you take a look at the code I posted in #15 in this thread: https://www.msofficeforums.com/vba/7...ction-etc.html you'll see that I work with up to four documents at a time, each of which is managed via a variable and none of which I need to make active for processing purposes. The 'master' document for each set is defined and managed via:
Code:
Set DocSrc = Documents.Open(FileName:=strInFold & "\" & strFile, AddTorecentFiles:=False, Visible:=False)
  With DocSrc
  ...
  End with
As for the programmer not anticipating '[Compatibility Mode]' in the window name, the same oversight probably made the software incompatible with any window-naming customizations a client might do.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #12  
Old 01-13-2012, 04:32 AM
madd madd is offline Word Visual Basic error - run time error 504 Windows XP Word Visual Basic error - run time error 504 Office 2010 32bit
Novice
 
Join Date: Jan 2012
Posts: 1
madd is on a distinguished road
Default

Hi

I came across this post when I had a very similar problem. In the end I found that if I went to Folder Options (for any folder), and the View tab. if you have it set to Hide extensions for known file types (the default) the mailings will not work, but if you take this option off, if is all fine!

I don't know if this will help anyone else, but it worked for me.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word: The document 'Filename' caused a serious error the last time ... martincruise Word 0 02-25-2010 01:47 AM
Runtime error 5487 - Word cannot complete the save to to file permission error franferns Word 0 11-25-2009 05:35 AM
Referencing Tables in Visual Basic Editor DavidB Word Tables 0 09-21-2009 04:01 PM
Receive error cannot open this form because an error occurred in BCM 2007 bornhusker Outlook 0 06-01-2009 10:28 AM
Word Visual Basic error - run time error 504 A little Visual Basic Help Please leroytrolley Excel 4 08-22-2008 03:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:34 PM.


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