zoseri
asked on
Problem printing labels
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.MailingL abel.Defau ltPrintBar Code = false;
//First I tried this line
oWord.Application.MailingL abel.Creat eNewDocume nt(ref Name,ref Address,ref missing,ref missing,ref missing);
//Then I tried this line
oWord.Application.MailingL abel.Print Out(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
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.MailingL
//First I tried this line
oWord.Application.MailingL
//Then I tried this line
oWord.Application.MailingL
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oWord.Application.Document
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!