Feedback Form
Showing posts with label Office. Show all posts
Showing posts with label Office. Show all posts

Friday, February 01, 2008

Excel file in new excel instance

You can open any excel file using code like this:

Process.Start(filePath);

But what will happen if we have these 2 lines of code:

Process.Start(filePathONE);

Process.Start(filePathTWO);

Will first open “filePathONE” in a new excel instance, then will open the “filePathTwo” in the same excel instance.

What we can do if we want to open each file in a separate new excel instance?

We must write it like that:

Process.Start(“Excel.exe”, filePathONE);

Process.Start(“Excel.exe”, filePathTWO);

It’s very simple, isn’t it?

But we can face a small problem with this way:

If you want to open an excel file that contains space in its name, for example “my Sheet.xls”, it will give you a runtime error that it can’t open files “my.xls” and “Sheet.xls”.

So what can I do?

It’s simple:

Just add “ before and after the file path, just like that:

Process.Start(“Excel.exe”, @“””filePathONE”””);

Like that it will open normally without any errors.

Note:

You will need to do the same for any office application (word, powerpoint, ….).

kick it on DotNetKicks.com

Access splash screen

How to add a splash screen that closes after 10 seconds before my main form starts?

Here is one way:
1. Place the form that has the splash screen in design view and set the following properties:
Timer Interval 6000
On Timer>>>>>>Click the build button to create an event procedure. Place the following code in that procedure:
________________________________________
Private Sub Form_Timer()
On Error GoTo Error_Routine
' Form stays open for 10 seconds, then closes.
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "frmMainSwitchboard"
Exit_Continue:
Exit Sub
Error_Routine:
MsgBox "Error# " & Err.Number & " " & Err.Description
Resume Exit_Continue
End Sub
______________________________________________
2. Go to Startup properties on the Access Command menu tools>Startup and select the splash screen as the form hat opens at startup. Then test by restarting your application access file.



kick it on DotNetKicks.com