Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Problem printing labels

Posted on 2005-05-09
3
Medium Priority
?
235 Views
Last Modified: 2012-05-05
I have a C# WinForms app and am trying to print labels from it.  I need to
print a label each time a certain type of record is added, so I need to print
labels one at a time.  I set up a Word application and it worked fine for other
purposes, but when I added this code I get the error:

"method or property is not available because a document window is not active"

Here is the code:
bool SingleLabel = true;
object Name = "4013";
object Address = ClName.Text +"\r\nTest Company Name\tTest Rep";

oWord.Application.MailingLabel.DefaultPrintBarCode = false;

//First I tried this line

oWord.Application.MailingLabel.CreateNewDocument(ref Name,ref Address,ref missing,ref missing,ref missing);

//Then I tried this line

oWord.Application.MailingLabel.PrintOut(ref Name,ref Address,ref missing,ref missing,ref SingleLabel, ref missing,ref missing);

I saw similar code in numerous examples and do not know what is missing.  In one place there was a suggestion that it could be a MS bug and to be sure I had Office SP3, but I upgraded it only to get same results.  Word version is 9.0.6926 SP-3.

Any help is appreciated.  I did not think this would be difficult but now it is threatening my deadline!!!!!!!!!!!!!!!!!!!

Thanks
zoseri
0
Comment
Question by:zoseri
2 Comments
 

Author Comment

by:zoseri
ID: 13969817
FIgured it out for myself - but thought I would post the answer in case anyone else runs into this problem....

oWord.Application.Documents.Add(ref missing, ref missing,
      ref missing, ref missing);

Have to add this before trying to print the label.  This has the effect of "new blank document".  I thought that CreateNewDocument would do this for me, but apparently not!
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 14248184
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question