Hi,
I created a group of macros in Word 2003 and they have been working fine. Recently a client upgrade to Office 2007. I went in and changed all the Application.FileSearch commands that I had in my macros, knowing that that command was no longer supported. But when I try to run the macros either from a shortcut or from the Add-in Ribbon menu I get an Error 5111 "This command is not availible on this platform". The macros run a shell ftp to copy a file from a UNIX server to the client hard drive and then does a Word mail merge using the transferred file as the data file.

If I open the template file (.dotm) in Word first and then run the macros from the menu they run without a problem.

The macros run fine on my developement PC. The one difference is that I have both Office 2003 and Office 2007 installed on my PC and the client installed an Office Standard Upgrade on their PC's. I have an older version of Office 2007 (12.0.6331.5000 SP1 MSO 12.0.6320.5000) where as the clients are running the latest (12.0.6425.1000 SP2 MSO 12.0.6425.1000).

Also, my references are still using the MSExcel 11.0 Object library where as the clients are using MSExcel 12.0 Object Library.

To run the macros from a shortcut I created a small exe in VB6.0 which accepts two parameters, checks those parameters, starts Word and using the parameters runs the a macro.

Anybody know what is tripping this up?

Thanks,
Steve

Dani AI

Generated

The symptom described by — macros run only after the .dotm is opened manually but fail with Error 5111 when Word is started programmatically — points to two converging issues: 1) the template/add-in containing the macros is not loaded when Word is launched by the VB6 launcher, and 2) Office 2007 removed the legacy FileSearch object (which can produce 5111-like behavior if still referenced). 's pointer about Excel libraries is relevant: different Office versions change references, so a cross-machine solution should avoid version-dependent references.

Practical fixes and checks:

  • Ensure the .dotm/add-in is actually loaded before running the macro. From automation, open or load the template explicitly and then call the macro by the full path/name so Word does not rely on the add-in being pre-installed.
  • Keep macros in a Trusted Location or sign them with a certificate instead of lowering macro security. (Word 2007: Office Button → Word Options → Trust Center → Trust Center Settings → Trusted Locations.)
  • Use late binding for Excel automation to avoid MSExcel 11.0 vs 12.0 reference problems; do not rely on project references that differ across machines.
  • Replace any remaining uses of Application.FileSearch with Dir or Scripting.FileSystemObject loops (these work in all supported Office versions).

Example automation pattern (minimal VB/VBA sketch):

Set wd = CreateObject("Word.Application")
wd.Visible = True
wd.AddIns.Add "C:\Path\MyAddin.dotm", True    'ensure add-in/template is loaded
wd.Run "C:\Path\MyAddin.dotm!ModuleName.MacroName", arg1

Debug checklist:

  • Start the same VB6 launcher on the client while watching Task Manager to confirm Word process and inspect Add-Ins (Office Button → Word Options → Add-Ins).
  • Test with Word visible and step through the macro; add logging or simple message boxes to isolate the failing line.
  • Do not rely on FileFormatConverter for Word 2007-to-2007 issues; it only helps older Office versions open newer formats.

These steps address the common causes behind Error 5111 in automated launches and avoid reference-version breakage that highlighted.

Recommended Answers

All 3 Replies

You need "FileFormatConverter.exe" (See attached zip)
It allows you to open any Office 2007 file in Office 2000

I got it from the Microsoft Site.

When you click the exe, you get the usual run around.
Click "Yes Install , Yes ok ok ok Just do it already".
Windows will set a restore point.

It allows you to open any Office 2007 file in Office 2000

It allows you to open any Office 2007 file in Office 2003

=========================================
Also, my references are still using the MSExcel 11.0 Object library where as the clients are using MSExcel 12.0 Object Library.
Your clients may have "MSExcel 11.0 Object library" they only have to check their references and checkmark it.

Your clients may have "MSExcel 11.0 Object library" they only have to check their references and checkmark it.

Oops! You can only have one object lubrary loaded at any one time!!!

About that other problem. Do you use an addin that refers to the server? If so, unload it, create an addin loader for that addin and put that code just before the request for files in the macro.

Before the program exits, unload the Addin.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.