|
I am attempting to write a function with the following declaration:
void OpenExcel(string filename, out Excel.ApplicationClass XLApp, out Excel.Workbook XLWorkBook, out Excel.Sheets XLSheets, out Excel.Worksheet XLWorkSheet)
where the function will open an instance of excel and the workbook with the given filename, and assign the application instance, the workbook, the worksheets collection and the default worksheet to the variables passed in respectively
When I attempt to compile I receive the following errors:
Argument '2': cannot convert from 'Microsoft.Office.Interop.Excel.Application' to 'out Microsoft.Office.Interop.Excel.ApplicationClass'
Argument '3': cannot convert from 'Microsoft.Office.Interop.Excel.Workbook' to 'out Microsoft.Office.Interop.Excel.Workbook'
Argument '4': cannot convert from 'Microsoft.Office.Interop.Excel.Sheets' to 'out Microsoft.Office.Interop.Excel.Worksheets'
Argument '5': cannot convert from 'Microsoft.Office.Interop.Excel.Worksheet' to 'out Microsoft.Office.Interop.Excel.Worksheet'
This also fails when I replace "out" with "ref"
Anyone know how to fix this?
|
|
|
|
|
Aren't you missing the "out" modifier in the calling function?
[]'s
Vini
|
|
|
|
|
Whoops, I'm amazed that I missed that
|
|
|
|
|
i am now working in a web developing project and bind the web page with sql server.
my question is: I want to handle the tricks that may cause any crash in sql when a user type "slash" or anything like this or any equation make the sql accept what he wrote
thanks in advance.
haitham
|
|
|
|
|
|
Is it possible to display a RTF file in my RichTextBox control?
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
nevermind. just found it
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
You are mastering the art of finding the answers for your own questions! =)
Good job!
Vini
|
|
|
|
|
Hi All,
I've recently tackled a project that involves a little bit of DirectX in managed code (c# with the June 06 DirectX SDK). I'm wondering if anyone has any recommendations for a good DirectX book? Something that focuses on managed DirectX, for someone who is comfortable programming in c# (a lot of the DirectX related stuff is sort of geared to people with very little development background). Just wondering if anyone here has run across a good reference that they would recommend.
Thanks,
Aaron
|
|
|
|
|
I want to put a copyright symbol inside a label
I tried alt+ctrl+C, but it didnt output anything. Any ideas?
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Two approaches:
1) Go to Character Map, find ©. Copy and paste it to your control
2) Find the ASCII code (or Unicode) for © (ASCII code is 169 in my RedHat Linux). Directly use the code in your application.
Best,
Jun
|
|
|
|
|
|
Hi guys;
I have a configuration form with tab controls where I have next and back buttons and I would like to disable the tab buttons, is there any way I can show the tab buttons but not allow the user to click on them and instead have them use the back and next buttons?
Please help!!!
sasa
|
|
|
|
|
i'm not sure if u can do it.
maybe u could use the user controls and with the buttons next/back u could show/hide them.
enrico
VentoEngine corp.
Program your life ^^
|
|
|
|
|
I've created a login dialog box to an application, which works fine, but now the customer wants to change to using a system login to the application to track who's on without needing to create separate login's in the app for each person. Also, the person running the app may or may not be the same person that logged into the computer (most likely not).
I've been digging around, and found some promising things - but nothing that quite matched up completely. The NetworkCredential class seemed the most promising, but I'm not going to be accessing any resource, I only need to see if it's a valid login, so I couldn't see how I could use this. The WindowsIdentity class also seemed promising, but I didn't see how that could be used for my purposes either.
Any ideas?
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
<br />
[DllImport("advapi32.dll", SetLastError = true)]<br />
public static extern bool LogonUser(String lpszUsername, <br />
String lpszDomain, String lpszPassword,<br />
int dwLogonType, int dwLogonProvider, ref IntPtr phToken);<br />
<br />
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]<br />
public extern static bool CloseHandle(IntPtr handle);<br />
<br />
private bool LogonUser()<br />
{<br />
IntPtr tokenHandle = new IntPtr(0);<br />
const int LOGON32_PROVIDER_DEFAULT = 0;<br />
const int LOGON32_LOGON_INTERACTIVE = 3;<br />
<br />
tokenHandle = IntPtr.Zero;<br />
string DomainName = ConfigurationManager.AppSettings["Domain"];<br />
<br />
try<br />
{<br />
if(LogonUser(txtName.Text, DomainName, txtPwd.Text,<br />
LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT,<br />
ref tokenHandle))<br />
{<br />
WindowsIdentity WinIdentity = new WindowsIdentity(tokenHandle);<br />
System.Threading.Thread.CurrentPrincipal =<br />
new WindowsPrincipal(WinIdentity);<br />
<br />
return true;<br />
}<br />
else<br />
{<br />
return false;<br />
}<br />
}<br />
catch(SystemException)<br />
{<br />
MessageBox.Show("Domain could not be found. Check network connection.");<br />
DialogResult = DialogResult.Abort;<br />
}<br />
catch(Exception ex)<br />
{<br />
ExceptionPolicy.HandleException(ex, "Unhandled Exception Policy");<br />
DialogResult = DialogResult.Abort;<br />
}<br />
finally<br />
{<br />
if( tokenHandle != IntPtr.Zero )<br />
CloseHandle(tokenHandle);<br />
}<br />
}<br />
only two letters away from being an asset
|
|
|
|
|
Beautiful! I wasn't quite expecting a full solution, but definite thanks! Works perfectly!
-----
In the land of the blind, the one eyed man is king.
|
|
|
|
|
I just happened to have it lying around from a recent project.
only two letters away from being an asset
|
|
|
|
|
Ok,
I can not for the life of me figure out what is going on here. The problem is that another process is locking one of the files I am trying to read. All I want to do is get the contents of the file and parse them. I'm not writing to the file at all. How can I make this thing work? The only option I can think of is to make a temporary copy of the file and then open that, but that seems rather hackish. The process locking the file is mission critical and runs for hours.
This program is essentially an attempt on my part to periodically parse the logs and notify me if there are errors.
I have the following function:
static string GetFileContents(string fileName)
{
bool success = false;
string ret = string.Empty;
FileInfo fi = new FileInfo(fileName);
while(!success)
{
try
{
using(FileStream fs = fi.Open(FileMode.Open, FileAccess.Read))
{
Console.WriteLine("Reading File {0}", fi.Name);
using(StreamReader sr = new StreamReader(fs))
{
ret = sr.ReadToEnd();
}
fs.Close();
success = true;
}
}
catch(Exception ex)
{
//Some sort of problem reading the file - we'll wait and then try again.
Console.WriteLine("Trouble reading file {0} - Will wait 5 minutes and try again. {1}", fi.Name,DateTime.Now);
System.Diagnostics.Debug.WriteLine(ex);
Thread.Sleep(300000);
}
}
return ret;
}
|
|
|
|
|
Hello
Few Questions:
1- Did you make these logs?? If not, then maybe the other program that made them, is exclusively opening them.
2- Can you open them using the notepad?
3- What exactly is the exception thrown when you open the file??
4- Is it thrown upon File.Open() or upon sr.ReadToEnd() Excution?
5- Do they open upon retrial sometimes, or are they always locked??
Regards
|
|
|
|
|
Hi all,
I have created a class library project in .Net C#.
I want to create a multiple instance of this control in a form based application, same as we create buttons.
But when i drop the control second time, the previous gets disappear. At a time i can see only one instance of control on form, internally it creates different objects of the control.
Please suggest me, how can i do it.
Thanks.
Gajesh
Pune(India)
|
|
|
|
|
ooooook guys heres a little tinker for ya!
im trying to read some fields from Flash FXP (in c#) using the Windows User32 API...
GetWindowText is what il be using...
so i use Microsoft Spy++ to get the Handle for one of the input boxes, lets say for arguments sake its 4134644.. (thats the handle to the text box...)
Spy++ reports this as an EDIT class, good so far!
so i use GetWindowText to try get the text from the text box.... empty string??
mmmmm so im stratching my head... i know ill test my code and use:
static extern int GetWindowTextLength(IntPtr hWnd)
this has got to work! i should get a length back now!! NOPE! nothing is coming back from ANY EDIT class field
HOWEVER if i use GetWindowText on anything else, Labels, Window Titles it works!!
What am i doing wrong here? Am i using the wrong API call to get data from an Edit Field?
its driving me mad!!! lol
|
|
|
|
|
wbjohnson wrote: this has got to work!
No, it doesn't! Just because the control derives from EDIT does NOT mean that you can use this, or any other method you want for getting the text out of the control. It will only work if the control responds to WM_GETTEXT, which not every EDIT control does.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
ah hah!!
that explains alot! thanks!
can i send the WM_GETTEXT command and then read the message buffer? assuming the control supports this command?
Cheers dude!
|
|
|
|
|
Yes. You might want to try these[^]. You might also want to look at the limitations of GetWindowText[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|