Results 1 to 16 of 16

Thread: [RESOLVED] word application declaration error

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Resolved [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

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: word application declaration error

    Post your code...
    Please mark you thread resolved using the Thread Tools as shown

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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.
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Re: word application declaration error

    Yes. But Both the system having MS word2007. But the application will generate and save it in word2003 format.

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Question 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

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    Re: word application declaration error

    vb Code:
    1. Imports Microsoft
    2. Imports Word = Microsoft.Office.Interop.Word
    3. Imports Microsoft.Win32
    4. Imports System.Runtime.InteropServices
    5. Imports System
    6. Imports System.Drawing
    7. Imports System.Drawing.Imaging
    8.  
    9. Public Class MainWindow
    10.  
    11.     '--- Windows API declarations
    12.     'Private Const WM_HOTKEY As Integer = &H312
    13.     Private Const MOD_ALT As Integer = &H1
    14.     Private Const MOD_CONTROL As Integer = &H2
    15.     Private Const MOD_SHIFT As Integer = &H4
    16.     Public Shared SysTray As New NotifyIcon()
    17.     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
    18.     Private Declare Function UnregisterHotKey Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal id As Integer) As Boolean
    19.     Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As IntPtr) As Boolean
    20.  
    21.     ' New Code
    22.     Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal nAtom As Short) As Short
    23.     Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Short
    24.     Dim hotkeyID As Short
    25.  
    26.     Public WordApp As Word.Application
    27.     Public doc As Word.Document
    28.     Public FrstFlag, TxtFlag As Boolean
    29.     Dim LogLib, LogFile As String
    30.     Dim Zero_Str As String
    31.     Dim CurIndex_Int As Integer
    32.  
    33. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    34.         Dim Rng As Word.Range
    35.         'UnregisterHotKey(Me.Handle, 0)
    36.         UnregisterGlobalHotKey()
    37.  
    38.         Try
    39.             If Trim(UCase(Set_Button.Text)) = "RE&SET" Then
    40.                 'If TxtFlag Then
    41.                 Rng = doc.Range
    42.                 Rng.Collapse(Word.WdCollapseDirection.wdCollapseStart)
    43.                 Rng.Delete()
    44.                 TxtFlag = False
    45.                 'End If
    46.  
    47.                 doc.SelectAllEditableRanges()
    48.                 WordApp.Selection.ShapeRange.WrapFormat.Type = Word.WdWrapType.wdWrapSquare
    49.  
    50.                 doc.Save()
    51.                 doc.Close()
    52.                 FrstFlag = False
    53.             End If
    54.  
    55.         Catch ex As NullReferenceException
    56.  
    57.         End Try

  9. #9
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: word application declaration error

    I doubt his machine doesnt have Winword Installed
    Please mark you thread resolved using the Thread Tools as shown

  12. #12
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    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.

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: word application declaration error

    Can you verify that you have the Primary Interop Assemblies installed?
    If not you will need to install them.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Jan 2009
    Posts
    92

    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:-(

  16. #16
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] word application declaration error

    Did you package the PIAs for deployment on other systems that have Word installed?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width