I need to disable Microsoft Word start screen programatically using C# in Visual Studio. I don't want to do it manually like this .
Anyone can help ?
I found a good workaround for it. It is simply to open a new blank document on startup
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
if (Application.Documents.Count == 0)
{
Application.Documents.Add();
}
}
Related
I am new to VSTO and C# and have a question regarding events.
I'm trying to fire an event when the user selects something within PowerPoint (e.g. a shape, slide, etc).
I found a working solution for VBA in the Office documentation here and some more info for a Word selection handler here, however I'm clueless on how and where to add it in my ThisAddIn.cs context.
I'm currently working from a fresh C# PowerPoint VSTO Addin
Any pointers into the right direction are highly welcome. Thanks!
Found this and it works:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
this.Application.WindowSelectionChange += Application_WindowSelectionChange;
}
private void Application_WindowSelectionChange(PowerPoint.Selection Sel)
{
//throw new NotImplementedException();
MessageBox.Show("Hello");
}
I created an app with VS2017 C# WinForms, created a report for a table inside with RDLC reportviewer, the report is working well, I want to print this report directly and send it to the printer without popping up print preview dialog.
Please be informed that I googled this issue and searched this site as well and I couldn't find a solution.
Tried to use the MSDN topic (Walkthrough: Printing a Local Report without Preview) but still no luck.
Here is my button which runs several queries including opening a form (voucher) containing an rdlc reportviewer which loads data to show up in the report:
private void button12_Click(object sender, EventArgs e)
{
SoundPlayer player = new SoundPlayer(Properties.Resources.switch_8);
player.Play();
if (string.IsNullOrWhiteSpace(textBox1.Text) || textBox1.Text == "0")
{
MessageBox.Show("Please select an item!");
}
else
{
MOVE_TO_SOLD();
UPDATE_RECEIPT();
LOAD_DATA();
CLEAR_TEMP();
CHECK_FOR_REC_ID();
GET_NEW_REC_ID();
LOAD_DATA();
txtdiscount.Text = "0";
textBox5.Text = "0";
recowner.Text = recnum.Text;
voucher vr = new voucher();
vr.ShowDialog();
}
}
Thank You!
This Walkthrough will be very helpful for your problem. Please check it out, and if this answer was helpful, mark it as an answer.
I'm trying to write a plugin for Outlook 2013 that processes content of emails.
So far, I've created an Outlook Addin-project in Visual Studio. Furthermore, I created a ribbon button, with
RibbonType = Microsoft.Outlook.Mail.Read
to show the button only when an email is read.
Is it possible get access to the email in order to e.g. show the subject or the content (consisting of plain text)?
private void button1_Click(object sender, Ribbon ControlEventArgs e)
{
System.Windows.Forms.MessageBox.Show( ... );
}
Use the RibbonControlEventArgs.Control property to get to the RiibbonControl object. You can then use the IRibbonControl.Context property and cast it to the Inspector object (for inspectors) or Explorer (for the Explorer buttons). Once you have the Inspector object, use the Inspector.CurrentItem property.
Thanks Dmitry for your help!
private void button1_Click(object sender, RibbonControlEventArgs e)
{
var mailItem = ((Inspector) e.Control.Context).CurrentItem;
MessageBox.Show(mailItem.Subject);
MessageBox.Show(mailItem.Body);
}
I know this has been discussed several times around here but the default behaviour for opening links
clicked in a WebBrowser control does not work for my application.
So while this works as in it opens a link clicked in IE:
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
System.Diagnostics.Process.Start(e.Url.ToString());
e.Cancel = true;
}
I am using a dropdown list to update the html file that the webBrowser is displaying like so:
private void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
webBrowser1.Url = myURI;
}
Now the problem I'm having is that with the _Navigating method above, the webBrowser does not load any subsequent changes to the URL (thanks to the e.cancel I guess) so it only displays the first html file it loads.
If I remove the _Navigating method it updates fine but then the links open up in the same webBrowser control which is what I do not want.
How can I get it to work both ways?
I hope this can help you.
If you want to open a link in a browser, you can add this simple code:
Process.Start("http://google.com");
Remember, there is a lot of information about it. Here in stack Overflow you can take a look in this post: How to open in default browser in C#
If you want to open your link in another browser, you can use this code:
System.Diagnostics.Process.Start("firefox.exe", "http://www.google.com");
Don't forget to visit this post called: How do I open alternative webbrowser (Mozilla or Firefox) and show the specific url?
And Finally, I could recommend you this stack overtflow post called: .NET C#: WebBrowser control Navigate() does not load targeted URL
I hope this information can help you a little bit.
This is an old post but I believe I may understand what the original poster wanted to do. They wanted a page to load in the webbrowser control if the user selected it from the dropdown list but any links in the loaded page should open in the user's web browser. If this is indeed the case, the original poster need a flag on the form to determine the behavior.
The original poster simply needed a flag such as linksOpenInSystemBrowser shown below.
using System;
using System.Windows.Forms;
namespace Browser_Test
{
public partial class myForm : Form
{
private bool linksOpenInSystemBrowser = false;
public myForm()
{
InitializeComponent();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
linksOpenInSystemBrowser = false;
webBrowser1.Navigate(comboBox1.SelectedItem.ToString());
}
private void webBrowser1_Navigating(object sender, WebBrowserNavigatingEventArgs e)
{
if(!linksOpenInSystemBrowser)
{
linksOpenInSystemBrowser = true;
return;
}
System.Diagnostics.Process.Start(e.Url.ToString());
e.Cancel = true;
}
}
}
I need to change the BackgroundImage of a button on click of another button (In Windows Forms in C#). But I can't find out how to do it!!
I searched on the internet and found many examples and all of them use ImageBrush, ImageSource etc.... but these don't work on my application, it shows me errors every time I Use them.
I read on the internet that I have to add this namespace:
using Windows.UI.Xaml.Media.Imaging;
But it shows me an error on the begging which says to add this System before Windwons and when I add it:
using System.Windows.UI.Xaml.Media.Imaging;
it shows me than the error at UI .... I can't figure it out how to solve this!!
Please help me guys!
To Change Background Image of a button there are two ways i know.
Add the Image to the resources folder of your project and use.
private void button2_Click(object sender, EventArgs e)
{
button1.BackgroundImage = Properties.Resources.ImageName;
}
Use Image.FromFile();
private void button2_Click(object sender, EventArgs e)
{
button1.BackgroundImage = Image.FromFile(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) + "//Card1.png");
}
You are trying to use solutions for WPF in Winforms. This will not work.
The class you need is System.Drawing.Image (or System.Drawing.Bitmap, which inherits from Image).
Bitmap b = new Bitmap(#"C:\myBitmap.jpg");
myButton.Image = b;
Be sure to call Dispose on your Bitmap if and when it is no longer in use.