- INDEX VB TO NET
- KNOWLEDGE BASE
- EWIS-ISSUES
- ISSUE #7008
WARNING #7008
The ProgId could not be found on computer where this application was migrated
Description
This specific issue arises when converting VB6 applications that use API calls to interact with programs from the Microsoft Office suite, such as Word , Excel or PowerPoint; the issue appears in in the upgraded code if the application is converted on a machien that does not have the Microsoft Office components installed.
Recommendations
There are two different options to remove the issue:
- Option 1: Install the Microsoft Office components and then convert the application again using VBUC.
- Option 2: Solve this issue manually.
If the there are too many occurrences of this issue in the upgraded code, Option 1 is the recommended one, otherwise Option 2 will work.
Sample VB6
Private Sub Form_Load() Dim oWordApplication As Object Set oWordApplication = GetObject(, "Word.Application") If oWordApplication Is Nothing Then Set oWordApplication = CreateObject("Word.Application") End If If oWordApplication Is Nothing Then Err.Raise vbObjectError + 1, , " Word Application not installed on MVBS server " End If End Sub
Target VB.NET
Private Sub Form_Load() Dim oWordApplication As Object = System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application") If oWordApplication Is Nothing Then 'UPGRADE_WARNING: (7008) The ProgId could not be found on computer where this application was migrated. oWordApplication = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application")) End If If oWordApplication Is Nothing Then Throw New System.Exception((Constants.vbObjectError + 1).ToString() + ", , Word Application not installed on MVBS server ") End If End Sub
Target C#
private void Form_Load() { object oWordApplication = Interaction.GetObject(String.Empty, "Word.Application"); if (oWordApplication is null) { //UPGRADE_WARNING: (7008) The ProgId could not be found on computer where this application was migrated. oWordApplication = Activator.CreateInstance(Type.GetTypeFromProgID("Word.Application")); } if (oWordApplication is null) { throw new System.Exception((Constants.vbObjectError + 1).ToString() + ", , Word Application not installed on MVBS server "); } }
For this sample the EWI can be addressed by adding a COM Reference to Word changing the Activator.CreatorInstance invocation for a direct instantiation of new Word Application object:
oWordApplication = New Word.Application