15,896,201 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Aleonis (Top 4 by date)
Aleonis
29-Apr-12 8:28am
View
Well, i looked at the format, added format type: wdFormatDocument and added .docx instead of simply .Doc.
Now i`m getting error: "type mismatch HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)"
Here is the code:
Object oSaveFileFormat = (Object)"wdFormatDocument";
wordDoc.SaveAs2(ref oSaveAsFile,
ref oSaveFileFormat,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing,
ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing);
I`ve tried also to leave format (wdFormatDocument parameter) as wMissing, while changing .doc to .docx - no effect. Error is still here...
Aleonis
28-Apr-12 10:52am
View
Saving data to the table depends on another algorithm that is going to be tested after is sort this one out. I have updated my question and it contains code and description now.
I`m trying to understand why my piece of code creates document according to a template (what was intended), but breaks order and position of information in created document (what was not supposed to happen at all) every time i execute code mentioned in my 1st message.
Aleonis
28-Apr-12 10:04am
View
Deleted
Hello Wes Aday and thank you for response, i will clarify.
I`m creating application that uses Microsoft Word 2007 as a report tool - printing certain documents from their respective templates.
It fails to do so.
Here is a piece of code:
private void ManagersDoc_Click(object sender, EventArgs e)
{
Object wMissing = System.Reflection.Missing.Value;
Object wTrue = true;
Object wFalse = false;
Word.Application wordApp = new Word.Application();
Word.Document wordDoc = new Word.Document();
wordApp.Visible = true;
Object docPath = @"J:\Quar.dotm"; // Path to Document Template
wordDoc = wordApp.Documents.Add(ref docPath, ref wMissing, ref wTrue, ref wTrue);
... // Interaction with Database PostgeSQL 9.1.2.
Object oSaveAsFile = @"J:\\SampleDoc.doc";
wordDoc.SaveAs(ref oSaveAsFile, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing);
wordApp.Quit();
We have template of document that is going to be printed, it has:
1) Two tables
2) Captions
3) Markers
All is neat, clean and takes 50 roughly percent of sheet.
What code is supposed to do:
1) Create a new Word document from "Quar.dotm" Template.
2) Fill it with data exactly as it is in template
What it does:
1) Create a new word Document from "Quar.dotm" template.
2) Fill it with data in such way that you have to manually place all tables,
captions and markers in it. In addition to that, in preview mode (where
MsWord shows how this document will look on paper) everything is split on 2
pages, 2 tables randomly re-sized and scattered across two pages.
IDE: Visual Studio 2010
Language: C# 3.0
Reason why C# 3.0 - app is going to be deployed on Windows XP.
.Net Framework version: 3.5
What i`m doing wrong here?
Aleonis
28-Apr-12 10:03am
View
Deleted
Hello Richard and thank you for your response, i will clarify.
I`m creating application that uses Microsoft Word 2007 as a report tool - printing certain documents from their respective templates.
It fails to do so.
Here is a piece of code:
private void ManagersDoc_Click(object sender, EventArgs e)
{
Object wMissing = System.Reflection.Missing.Value;
Object wTrue = true;
Object wFalse = false;
Word.Application wordApp = new Word.Application();
Word.Document wordDoc = new Word.Document();
wordApp.Visible = true;
Object docPath = @"J:\Quar.dotm"; // Path to Document Template
wordDoc = wordApp.Documents.Add(ref docPath, ref wMissing, ref wTrue, ref wTrue);
... // Interaction with Database PostgeSQL 9.1.2.
Object oSaveAsFile = @"J:\\SampleDoc.doc";
wordDoc.SaveAs(ref oSaveAsFile, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing, ref wMissing, ref wMissing,
ref wMissing);
wordApp.Quit();
We have template of document that is going to be printed, it has:
1) Two tables
2) Captions
3) Markers
All is neat, clean and takes 50 roughly percent of sheet.
What code is supposed to do:
1) Create a new Word document from "Quar.dotm" Template.
2) Fill it with data exactly as it is in template
What it does:
1) Create a new word Document from "Quar.dotm" template.
2) Fill it with data in such way that you have to manually place all tables,
captions and markers in it. In addition to that, in preview mode (where
MsWord shows how this document will look on paper) everything is split on 2
pages, 2 tables randomly re-sized and scattered across two pages.
IDE: Visual Studio 2010
Language: C# 3.0
Reason why C# 3.0 - app is going to be deployed on Windows XP.
.Net Framework version: 3.5
What i`m doing wrong here?