Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Office Interop Exception in VB.NET1.1, Please help

Office Interop Exception in VB.NET1.1, Please help

Scheduled Pinned Locked Moved Visual Basic
csharpcomhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Puneet Bhatnagar
    wrote on last edited by
    #1

    Hi, I am using VB.NET1.1 and office 2003. I have created a object of Word document, opening it, writing some data into the document Printing it and finally closing the document. However it is throwing this exception while closing the document. exception from hresult 0x800A140C Here is the code piece: If (IsNothing(appWord) = True) Then appWord = ModWord.GetWordApplication End If docProposal = ModWord.GetDocument(appWord, lstrFileName) lstrFileName = docProposal.FullName lstrFile = docProposal.Name If (docProposal.MailMerge.Fields.Count > 0) Then For Each bk As Word.MailMergeField In docProposal.MailMerge.Fields bk.Locked = True Next ' Create a data source containing the field data. docProposal.MailMerge.CreateDataSource(Name:=lstrDataFile, HeaderRecord:="1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37") ' Open the file to insert data. 'docProposalData = appWord.Documents.Add(lstrDataFile, Visible:=False) docProposalData = appWord.Documents.Open(lstrDataFile, Visible:=False) With docProposalData.Tables.Item(1) lint = 1 For Each lstr In laHdg .Cell(1, lint).Range.Text = lstr lint += 1 Next lint = 1 For Each lstr In laData .Cell(2, lint).Range.Text = lstr lint += 1 Next End With ' Save and close the data file. docProposalData.SaveAs(lstrDataFile) Application.DoEvents() 'The code is breaking at this line. docProposalData.Close(Word.WdSaveOptions.wdDoNotSaveChanges, , False) Application.DoEvents() Please help For Reference here is GetDocument function Public Shared Function GetDocument(ByVal wordApplication As Word.Application, ByVal filename As String) As Word.Document If wordApplication Is Nothing Then Throw New ApplicationException("Word application is nothing.") End If Dim docProposal As Word.Document = wordApplication.Documents.Open(filename) If filename.EndsWith(".dot") Then For Each templ

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups