Click here to Skip to main content
15,916,188 members
Home / Discussions / C#
   

C#

 
GeneralC++ and Bios Pin
SESCO LIBYA3-Mar-05 22:42
SESCO LIBYA3-Mar-05 22:42 
GeneralRe: C++ and Bios Pin
leppie3-Mar-05 23:38
leppie3-Mar-05 23:38 
GeneralWindows Service & SendMessage Pin
s211197923-Mar-05 22:15
s211197923-Mar-05 22:15 
GeneralRe: Windows Service & SendMessage Pin
mav.northwind3-Mar-05 22:23
mav.northwind3-Mar-05 22:23 
GeneralRe: Windows Service & SendMessage Pin
s211197923-Mar-05 22:38
s211197923-Mar-05 22:38 
GeneralRe: Windows Service & SendMessage Pin
mav.northwind4-Mar-05 0:45
mav.northwind4-Mar-05 0:45 
GeneralRe: Windows Service & SendMessage Pin
James Poulose4-Mar-05 2:49
James Poulose4-Mar-05 2:49 
GeneralUsing Word functions Pin
V.3-Mar-05 21:29
professionalV.3-Mar-05 21:29 
Hi,

I posted a thread yesterday about creating and printing documents with a template and text out of the database.

I was able to import an Office Object and to work with it. Setting the contents and I automatically get a 'save to' box.

Now I'm trying to use the open and printout function and here comes the problem: the required parameters are all of type ref object. When I create those objects and execute the function I get a 'Type Mismatch' error. Probably because the function tries to cast the objects to a certain type.

Does anyone know what the types are the function needs? Which parameters can be null? I found an example on MSDN, but, off course, this was VB and the function didn't have half as much parameters.

Here a sample of my code. (note, I don't know anything about automation and the object model, so I'm totally fishing here)
I need this for a demo, so nothing fancy is needed:
Get the data out of the database and print it (according to the correct template and with a number of copies).

<br />
foreach(DataRow row in ds.Tables[0].Rows){<br />
 while(File.Exists(path + "file" + index + ".rtf")){<br />
  index++;<br />
 }						//end while<br />
 object ob1 = row["templatename"], ob2 = 0, ob3 = 0;<br />
 object ob4 = 0, ob5 = "", ob6 = "";<br />
 object ob7 = 0, ob8 = 0, ob9 = 0;<br />
 object ob10 = "", ob11 = "", ob12 = 1;<br />
 object ob13 = 0, ob14 = 0, ob15 = 0;<br />
 object ob16 = 0;<br />
 try{<br />
  doc.Application.Documents.Open(ref ob1, ref ob2, ref ob3, ref ob4, ref ob5, ref ob6, ref ob7, ref ob8, ref ob9, ref ob10, ref ob11, ref ob12, ref ob13, ref ob14, ref ob15, ref ob16);<br />
 }<br />
 catch(Exception ex1){<br />
  MessageBox.Show("Open error:\n\n" + ex1);<br />
 }<br />
 doc.Content.Text = row["contents"] + "";<br />
 doc.Save();<br />
 //StreamWriter wr = File.CreateText(path + "file" + index + ".rtf");<br />
 //wr.Write(row["contents"] + "");<br />
 //wr.Close();<br />
 index++;<br />
}							//end foreach<br />
object	o1 = 0, o2 = 0, o3 = 0;<br />
object	o4 = "", o5 = 1, o6 = 1;<br />
object	o7 = 0, o8 = --index, o9 = 1;<br />
object	o10 = 1, o11 = 0, o12 = 0;<br />
object	o13 = 0, o14 = 0, o15 = 0;<br />
object	o16 = 0, o17 = 0, o18 = 0;<br />
try{<br />
 doc.PrintOut(	ref o1, ref o2, ref o3, ref o4, ref o5, ref o6, ref o7, ref o8, ref o9, ref o10, ref o11, ref o12, ref o13, ref o14, ref o15, ref o16, ref o17, ref o18);<br />
}<br />
catch(Exception ex2){<br />
 MessageBox.Show("PrintOut error:\n\n" + ex2);<br />
}<br />
<br />
object obj1 = false;<br />
object obj2 = null;<br />
object obj3 = null;<br />
//doc.Close(ref obj1, ref obj2, ref obj3);<br />
doc.Application.Quit(ref obj1, ref obj2, ref obj3);<br />


I hope somebody can help me.
tnx.

(PS: somebody pointed me out to Crystal Reports, but I don't know that either Sniff | :^) )

No hurries, no worries.
GeneralReading ID3 tags with Shell32 Pin
Rob Tomson3-Mar-05 20:44
Rob Tomson3-Mar-05 20:44 
Generalhelp me plz Pin
Member 17782963-Mar-05 20:42
Member 17782963-Mar-05 20:42 
GeneralRe: help me plz Pin
Sebastian Schneider3-Mar-05 22:16
Sebastian Schneider3-Mar-05 22:16 
GeneralRe: help me plz Pin
Member 17782963-Mar-05 22:36
Member 17782963-Mar-05 22:36 
GeneralRe: help me plz Pin
J4amieC3-Mar-05 22:39
J4amieC3-Mar-05 22:39 
GeneralRe: question Pin
Member 17782964-Mar-05 1:58
Member 17782964-Mar-05 1:58 
GeneralRe: Pin
Member 17782966-Mar-05 18:47
Member 17782966-Mar-05 18:47 
QuestionHow to dynamically add and use controls at runtime (use custom Pin
oohungoo3-Mar-05 19:56
oohungoo3-Mar-05 19:56 
GeneralProblem with MDI Child form. Pin
Saurabh Mundhra3-Mar-05 19:44
Saurabh Mundhra3-Mar-05 19:44 
GeneralRe: Problem with MDI Child form. Pin
Pushkar Pathak15-Mar-05 20:43
Pushkar Pathak15-Mar-05 20:43 
GeneralRead / Write an Image file Pin
Rob Tomson3-Mar-05 17:20
Rob Tomson3-Mar-05 17:20 
GeneralRe: Read / Write an Image file Pin
Yulianto.3-Mar-05 19:15
Yulianto.3-Mar-05 19:15 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 19:24
Rob Tomson3-Mar-05 19:24 
GeneralRe: Read / Write an Image file Pin
leppie3-Mar-05 20:36
leppie3-Mar-05 20:36 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 20:38
Rob Tomson3-Mar-05 20:38 
GeneralRe: Read / Write an Image file Pin
Sebastian Schneider3-Mar-05 22:24
Sebastian Schneider3-Mar-05 22:24 
GeneralRe: Read / Write an Image file Pin
Rob Tomson3-Mar-05 22:32
Rob Tomson3-Mar-05 22:32 

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.