[RESOLVED] word application declaration error
Hi im working on an application which will generate a word doc. Now i have moved to some other system. if i opened my vb project from the new machine its showing the word application is not declared. i have add the refference. but no use:-(
Help me !!
Thanks in advance
Re: word application declaration error
Re: word application declaration error
Does this new system contain the same version of Word? which version was on the original system and on this new system?
Re: word application declaration error
Ramesh, Rob has a valid question when he is asking which version are you using? Show the code where you are interacting/declaring with Word. I suspect that you must be using Early binding... You need to use Late Binding.
Re: word application declaration error
Yes. But Both the system having MS word2007. But the application will generate and save it in word2003 format.
Re: word application declaration error
Show the code where you are interacting/declaring with Word... Also the code where you are trying to save it as 2003 format... What is the FileFormat:xx number that you are using...
Re: word application declaration error
Imports Microsoft
Imports Word = Microsoft.Office.Interop.Word
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class MainWindow
'--- Windows API declarations
'Private Const WM_HOTKEY As Integer = &H312
Private Const MOD_ALT As Integer = &H1
Private Const MOD_CONTROL As Integer = &H2
Private Const MOD_SHIFT As Integer = &H4
Public Shared SysTray As New NotifyIcon()
Private Declare Function RegisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer, ByVal fsModifier As Integer, ByVal vk As Integer) As Integer
Private Declare Function UnregisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer) As Boolean
Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean
' New Code
Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal nAtom As Short) As Short
Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Short
Dim hotkeyID As Short
Public WordApp As Word.Application
Public doc As Word.Document
Public FrstFlag, TxtFlag As Boolean
Dim LogLib, LogFile As String
Dim Zero_Str As String
Dim CurIndex_Int As Integer
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Rng As Word.Range
'UnregisterHotKey(Me.Handle, 0)
UnregisterGlobalHotKey()
Try
If Trim(UCase(Set_Button.Text)) = "RE&SET" Then
'If TxtFlag Then
Rng = doc.Range
Rng.Collapse(Word.WdCollapseDirection.wdCollapseStart)
Rng.Delete()
TxtFlag = False
'End If
doc.SelectAllEditableRanges()
WordApp.Selection.ShapeRange.WrapFormat.Type = Word.WdWrapType.wdWrapSquare
doc.Save()
doc.Close()
FrstFlag = False
End If
Catch ex As NullReferenceException
End Try
Re: word application declaration error
vb Code:
Imports Microsoft
Imports Word = Microsoft.Office.Interop.Word
Imports Microsoft.Win32
Imports System.Runtime.InteropServices
Imports System
Imports System.Drawing
Imports System.Drawing.Imaging
Public Class MainWindow
'--- Windows API declarations
'Private Const WM_HOTKEY As Integer = &H312
Private Const MOD_ALT As Integer = &H1
Private Const MOD_CONTROL As Integer = &H2
Private Const MOD_SHIFT As Integer = &H4
Public Shared SysTray As New NotifyIcon()
Private Declare Function RegisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer, ByVal fsModifier As Integer, ByVal vk As Integer) As Integer
Private Declare Function UnregisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer) As Boolean
Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean
' New Code
Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal nAtom As Short) As Short
Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Short
Dim hotkeyID As Short
Public WordApp As Word.Application
Public doc As Word.Document
Public FrstFlag, TxtFlag As Boolean
Dim LogLib, LogFile As String
Dim Zero_Str As String
Dim CurIndex_Int As Integer
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim Rng As Word.Range
'UnregisterHotKey(Me.Handle, 0)
UnregisterGlobalHotKey()
Try
If Trim(UCase(Set_Button.Text)) = "RE&SET" Then
'If TxtFlag Then
Rng = doc.Range
Rng.Collapse(Word.WdCollapseDirection.wdCollapseStart)
Rng.Delete()
TxtFlag = False
'End If
doc.SelectAllEditableRanges()
WordApp.Selection.ShapeRange.WrapFormat.Type = Word.WdWrapType.wdWrapSquare
doc.Save()
doc.Close()
FrstFlag = False
End If
Catch ex As NullReferenceException
End Try
Re: word application declaration error
oh... this is vb.net
Well you have posted it in the wrong forum :) Request a mod to move it to vb.net forum.
Edit: I have requested a mod to move it :)
Re: word application declaration error
Thread Moved
Do you have the PIA's installed on this new system? (link in my signature)
Do you have Option Explicit On in your Options?
Re: word application declaration error
I doubt his machine doesnt have Winword Installed
Re: word application declaration error
If it didnt, he wouldnt have been able to add the Word reference unless the solution was just copied over to the new system without references being updated etc.
Re: word application declaration error
hi rob.. i have updated the word reference.. can u pls tell me wat are the reference need to update.
Re: word application declaration error
Can you verify that you have the Primary Interop Assemblies installed?
If not you will need to install them.
Re: word application declaration error
Thanks a lot.......now no errors:-) after publishing it when i try to install in a machiine it shows interop.word.dll is missing:-(
Re: [RESOLVED] word application declaration error
Did you package the PIAs for deployment on other systems that have Word installed?