TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sunil C
NA
1
1.2k
GetForegroundWindow(); with docs.ActiveWindow.Selection.Font
Jul 2 2016 8:52 AM
In my C# background (Tray) application, I am checking if foreground application is Office Word application, using following Function. It is working perfectly.
bool
WinWordApp()
{
IntPtr hwnd = GetForegroundWindow();
BringWindowToTop(hwnd);
uint
pid;
GetWindowThreadProcessId(hwnd,
out
pid);
Process p = Process.GetProcessById((
int
)pid);
string
AppName =
null
;
AppName = p.ProcessName.ToString();
if
(AppName.IndexOf(
"WinWord"
, StringComparison.CurrentCultureIgnoreCase) != -1)
return
true
;
else
return
false
;
}
My query: Using this
pid / p / AppName
, I want to just set font in the foreground Word application, to say
“Arial”
, without touching other attributes like font size, underline, bold etc. On the net I got some clues like:
objWord.Activewindow.Selection.Font.Name =
"Arial"
But I don’t know how to club these two.
Please help.
Reply
Answers (
0
)
[C#] Processing on Data (Excel)
Microsoft Access Query in a Word Document