Click here to Skip to main content
15,891,951 members
Home / Discussions / C#
   

C#

 
GeneralRe: My Code gets stuck at MessageBox.Show() after pressing OK it does not move further. Pin
jsc4210-Nov-22 5:08
professionaljsc4210-Nov-22 5:08 
GeneralRe: My Code gets stuck at MessageBox.Show() after pressing OK it does not move further. Pin
Radheya Patil10-Nov-22 16:39
Radheya Patil10-Nov-22 16:39 
GeneralRe: My Code gets stuck at MessageBox.Show() after pressing OK it does not move further. Pin
OriginalGriff10-Nov-22 20:18
mveOriginalGriff10-Nov-22 20:18 
QuestionRe: My Code gets stuck at MessageBox.Show() after pressing OK it does not move further. Pin
Eddy Vluggen11-Nov-22 6:37
professionalEddy Vluggen11-Nov-22 6:37 
AnswerRe: My Code gets stuck at MessageBox.Show() after pressing OK it does not move further. Pin
Gerry Schmitz11-Nov-22 6:46
mveGerry Schmitz11-Nov-22 6:46 
QuestionNet framework again Pin
Calin Negru8-Nov-22 7:59
Calin Negru8-Nov-22 7:59 
AnswerRe: Net framework again Pin
OriginalGriff8-Nov-22 10:05
mveOriginalGriff8-Nov-22 10:05 
GeneralRe: Net framework again Pin
Calin Negru8-Nov-22 22:01
Calin Negru8-Nov-22 22:01 
GeneralRe: Net framework again Pin
OriginalGriff8-Nov-22 23:14
mveOriginalGriff8-Nov-22 23:14 
GeneralRe: Net framework again Pin
Calin Negru9-Nov-22 4:00
Calin Negru9-Nov-22 4:00 
GeneralRe: Net framework again Pin
OriginalGriff9-Nov-22 4:12
mveOriginalGriff9-Nov-22 4:12 
AnswerRe: Net framework again Pin
Sam Hobbs8-Nov-22 17:59
Sam Hobbs8-Nov-22 17:59 
GeneralRe: Net framework again Pin
Richard Andrew x6420-Nov-22 6:34
professionalRichard Andrew x6420-Nov-22 6:34 
AnswerRe: Net framework again Pin
Gerry Schmitz8-Nov-22 18:02
mveGerry Schmitz8-Nov-22 18:02 
GeneralRe: Net framework again Pin
Richard Deeming8-Nov-22 21:38
mveRichard Deeming8-Nov-22 21:38 
GeneralRe: Net framework again Pin
Gerry Schmitz9-Nov-22 19:03
mveGerry Schmitz9-Nov-22 19:03 
GeneralRe: Net framework again Pin
Calin Negru8-Nov-22 22:06
Calin Negru8-Nov-22 22:06 
Question.NET Framework versus .NET latest? Pin
Bruce Greene7-Nov-22 8:59
Bruce Greene7-Nov-22 8:59 
AnswerRe: .NET Framework versus .NET latest? Pin
OriginalGriff7-Nov-22 9:39
mveOriginalGriff7-Nov-22 9:39 
AnswerRe: .NET Framework versus .NET latest? Pin
Mycroft Holmes7-Nov-22 10:47
professionalMycroft Holmes7-Nov-22 10:47 
GeneralRe: .NET Framework versus .NET latest? Pin
Bruce Greene7-Nov-22 11:01
Bruce Greene7-Nov-22 11:01 
AnswerRe: .NET Framework versus .NET latest? Pin
Gerry Schmitz8-Nov-22 4:57
mveGerry Schmitz8-Nov-22 4:57 
AnswerRe: .NET Framework versus .NET latest? Pin
Jacques Fournier13-Nov-22 11:10
Jacques Fournier13-Nov-22 11:10 
AnswerRe: .NET Framework versus .NET latest? Pin
jschell14-Nov-22 6:32
jschell14-Nov-22 6:32 
QuestionAnyone seen this odd Word Interop behavior? Pin
RobertSF3-Nov-22 11:00
professionalRobertSF3-Nov-22 11:00 
Using C# and Word 16.0.

C#
var wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
Document wordDoc1 = wordApp.Documents.Add();
Document wordDoc2 = wordApp.Documents.Open(@"c:\users\robertsf\desktop\doc2.docx");
When this code executes, wordDoc1 gets clobbered, everything returning COM Exception, and wordApp.Documents contains only one object, the opened document.

C#
var wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
Document wordDoc1 = wordApp.Documents.Add();
Document wordDoc1a = wordApp.Documents.Add();
Document wordDoc2 = wordApp.Documents.Open(@"c:\users\robertsf\desktop\doc2.docx");
When this code executes, wordDoc1 gets clobbered again, but wordDoc1a is fine, and wordApp.Documents contains two objects.

C#
var wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
Document wordDoc2 = wordApp.Documents.Open(@"c:\users\robertsf\desktop\doc2.docx");
Document wordDoc1a = wordApp.Documents.Add();
When this code executes, however, everything is fine. wordApp.Documentscontains two objects, and each object is accessible, as expected.

I'm trying to programmatically create a new document and copy the text of a variable number of documents into it. I suppose I could open all the source documents before creating the destination document. Or I could try to create two instances of Word.Application, one for the source documents and one for the destination document, and then see if I can copy between the two instances.

Here's the MS documation.
Add: Documents.Add(Object, Object, Object, Object) Method (Microsoft.Office.Interop.Word) | Microsoft Learn[^]
Open: Documents.Open Method (Microsoft.Office.Interop.Word) | Microsoft Learn[^]

I don't see anything about one operation overwriting the other. ¯\_(ツ)_/¯

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.