Error : ActiveX component can’t create object: ‘Word.Application’ in Windows XP

vbscript

Below code is running fine in Windows 7.I am getting the error "ActiveX component can't create object: 'Word.Application'" in Windows XP.
Microsoft Word is not installed in the XP, Is this the cause for the error?
I am new to vbscript.
What is the resolution for this?

Const msoFileDialogOpen = 1

Set fso = CreateObject("Scripting.FileSystemObject")
Set objWord = CreateObject("Word.Application")
Set WshShell = CreateObject("WScript.Shell")

strInitialPath = WshShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Desktop\"

objWord.ChangeFileOpenDirectory(strInitialPath)

With objWord.FileDialog(msoFileDialogOpen)

   .Title = "Select the file to process"
   .AllowMultiSelect = False

   .Filters.Clear

   .Filters.Add "All Files", "*.*"
   .Filters.Add "Excel Files", "*.xls;*.xlsx"
   .Filters.Add "Text Files", "*.txt"
   .Filters.Add "Various Files", "*.xls;*.doc;*.vbs"
   If .Show = -1 Then  'short form

      For Each File in .SelectedItems  'short form
         Set objFile = fso.GetFile(File)
         WScript.Echo objFile.Path
      Next    
   Else 
   End If
End With

'Close Word
objWord.Quit

Best Answer

Yes, if MS Word is not installed in the computer no "Word.Application" can be created because it doesn't even exist in your system.

The easiest way to resolve this is installing MSWord in the computer. The hard way involves locating the activeX assemblies and its dependencies and register it in the computer manualy.

You can use http://www.nirsoft.net/utils/axhelper.html to check the list of ActiveX components instaled in a computer.

-- Can Openoffice resolve this instead of MS Word?

Ofcourse, check this link

Related Topic