Click here to Skip to main content
15,949,741 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Change workbook for read/ write Pin
stephan06074-Mar-10 9:29
stephan06074-Mar-10 9:29 
GeneralRe: Change workbook for read/ write Pin
Dave Kreskowiak4-Mar-10 11:06
mveDave Kreskowiak4-Mar-10 11:06 
QuestionBackground color of message box Pin
Tufail Ahmad4-Mar-10 2:47
Tufail Ahmad4-Mar-10 2:47 
AnswerRe: Background color of message box Pin
Dave Kreskowiak4-Mar-10 3:44
mveDave Kreskowiak4-Mar-10 3:44 
GeneralRe: Background color of message box Pin
Tufail Ahmad4-Mar-10 18:05
Tufail Ahmad4-Mar-10 18:05 
GeneralRe: Background color of message box Pin
Anubhava Dimri4-Mar-10 18:19
Anubhava Dimri4-Mar-10 18:19 
GeneralRe: Background color of message box Pin
Dave Kreskowiak5-Mar-10 2:02
mveDave Kreskowiak5-Mar-10 2:02 
QuestionOffice Interop Exception in VB.NET1.1, Please help Pin
Puneet Bhatnagar4-Mar-10 1:53
Puneet Bhatnagar4-Mar-10 1:53 
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.
<b>exception from hresult 0x800A140C</b> 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.
<b>docProposalData.Close(Word.WdSaveOptions.wdDoNotSaveChanges, , False)
Application.DoEvents()</b>

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 template As Word.Template In wordApplication.Templates
If filename.EndsWith(template.Name) Then
template.Saved = True
End If
Next
filename = filename.Substring(0, filename.IndexOf(".dot")) & ".doc"
docProposal.SaveAs(filename)
End If

Return docProposal
End Function

Thanks & Regards
Puneet
QuestionGDI+ help Pin
nyt19723-Mar-10 23:43
professionalnyt19723-Mar-10 23:43 
AnswerRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 0:50
professionalWayne Gaylard4-Mar-10 0:50 
AnswerRe: GDI+ help Pin
Dave Kreskowiak4-Mar-10 1:53
mveDave Kreskowiak4-Mar-10 1:53 
GeneralRe: GDI+ help Pin
nyt19724-Mar-10 19:24
professionalnyt19724-Mar-10 19:24 
GeneralRe: GDI+ help Pin
Wayne Gaylard4-Mar-10 21:31
professionalWayne Gaylard4-Mar-10 21:31 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 0:01
professionalnyt19725-Mar-10 0:01 
GeneralRe: GDI+ help Pin
Wayne Gaylard5-Mar-10 0:57
professionalWayne Gaylard5-Mar-10 0:57 
GeneralRe: GDI+ help Pin
nyt19725-Mar-10 1:13
professionalnyt19725-Mar-10 1:13 
GeneralRe: GDI+ help Pin
Wayne Gaylard5-Mar-10 1:51
professionalWayne Gaylard5-Mar-10 1:51 
GeneralRe: GDI+ help Pin
Dave Kreskowiak5-Mar-10 2:10
mveDave Kreskowiak5-Mar-10 2:10 
AnswerRe: GDI+ help Pin
Luc Pattyn5-Mar-10 1:55
sitebuilderLuc Pattyn5-Mar-10 1:55 
GeneralRe: GDI+ help Pin
nyt19727-Mar-10 20:35
professionalnyt19727-Mar-10 20:35 
QuestionWorking with CR in VB.net Pin
C#Coudou3-Mar-10 23:03
C#Coudou3-Mar-10 23:03 
AnswerRe: Working with CR in VB.net Pin
Anubhava Dimri4-Mar-10 18:25
Anubhava Dimri4-Mar-10 18:25 
QuestionHow to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
karthickmani633-Mar-10 17:31
karthickmani633-Mar-10 17:31 
AnswerRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
Dalek Dave3-Mar-10 21:47
professionalDalek Dave3-Mar-10 21:47 
GeneralRe: How to Open a Third Party Application in a Form/Webbrowser in VB6 Pin
karthickmani633-Mar-10 23:33
karthickmani633-Mar-10 23:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.