VBA Code :-
Private Sub GetUserName()
With UserForm1
.lstRegions.AddItem "North"
.lstRegions.AddItem "South"
.lstRegions.AddItem "East"
.lstRegions.AddItem "West"
.txtSalesPersonID.Text = "00000"
.Show
' ...
End With
End Sub
C# Code :-
Add Form Name "UserForm1"
Create 2 public Method
public void AddItemtolIst(string value)
{
lstRegions.Items.Add(value);
}
public void AddItemToText(string strvalue)
{
txtSalesPersonID.Text = strvalue;
}
and Now acess that in ThisDocument file..
private void GetUserName()
{
UserForm1 UF = new UserForm1();
UF.AddItemtolIst("North");
UF.AddItemtolIst("South");
UF.AddItemtolIst("East");
UF.AddItemtolIst("West");
UF.AddItemToText("Avinash");
}
VBA Code :-
'Code in module to declare public variables
Public strRegion As String
Public intSalesPersonID As Integer
Public blnCancelled As Boolean
'Code in form
Private Sub cmdCancel_Click()
Module1.blnCancelled = True
Unload Me
End Sub
Private Sub cmdOK_Click()
'Save data
intSalesPersonID = txtSalesPersonID.Text
strRegion = lstRegions.List(lstRegions.ListIndex)
Module1.blnCancelled = False
Unload Me
End Sub
Sub LaunchSalesPersonForm()
frmSalesPeople.Show
If blnCancelled = True Then
MsgBox "Operation Cancelled!", vbExclamation
Else
MsgBox "The Salesperson's ID is: " & _
intSalesPersonID & _
"The Region is: " & strRegion
End If
End Sub
C# Code :-
public string strRegion;
public int intSalesPersonId = 0;
public bool blnCancelled;
private void cmdCancel_Click()
{
blnCancelled = true;
UserForm1 uf = new UserForm1();
uf.Close();
}
private void cmdOK_Click()
{
intSalesPersonId = Convert.ToInt16(txtSalesPersonID.Text);
strRegion = lstRegions.Text;
blnCancelled = false;
UserForm1 uf = new UserForm1();
uf.Close();
}
public void LaunchSalesPersonForm()
{
UserForm1 uf = new UserForm1();
uf.Show();
if (blnCancelled == true)
{
MessageBox.Show("Operation Cancelled !");
}
else
{
MessageBox.Show("The Salesperson's ID is: " + intSalesPersonId + "The Region is: " + strRegion);
}
}
VBA Code :-
Sub ShowOpenDialog()
Dialogs(wdDialogFileOpen).Show
End Sub
C# Code :-
public void ShowOpenDialog()
{
int intvalue = ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFileOpen].Show(ref missing);
}
VBA Code :-
Sub ShowPrintDialog()
Dialogs(wdDialogFilePrint).Show
End Sub
C# Code : -
public void ShowPrintDialog()
{
int intvalue = ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFilePrint].Show(ref missing);
}
VBA Code :-
Sub ShowBorderDialog()
With Dialogs(wdDialogFormatBordersAndShading)
.DefaultTab = wdDialogFormatBordersAndShadingTabPageBorder
.Show
End With
End Sub
C# Code :-
public void ShowBorderDialog()
{
ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatBordersAndShading].DefaultTab = Word.WdWordDialogTab.wdDialogFormatBordersAndShadingTabPageBorder;
int intvalue = ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatBordersAndShading].Show(ref missing);
}
VBA Code :-
Sub DisplayUserInfoDialog()
With Dialogs(wdDialogToolsOptionsUserInfo)
.Display
MsgBox .Name
End With
End Sub
C# Code :-
public void DisplayUserInfoDialog()
{
string strvalue = ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogToolsOptionsUserInfo].Application.UserName ;
MessageBox.Show(strvalue);
}
VBA Coded :-
Sub DisplayUserInfo()
MsgBox Application.UserName
End Sub
C# Code :-
public void DisplayUserInfo()
{
String strvalue = ThisApplication.UserName;
}
VBA Code :-
Sub ShowAndSetUserInfoDialogBox()
With Dialogs(wdDialogToolsOptionsUserInfo)
.Display
If .Name <> "" Then .Execute
End With
End Sub
C# Code :-
public void ShowAndSetUserInfoDialogBox()
{
ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogToolsOptionsUserInfo].Display(ref missing);
ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogToolsOptionsUserInfo].Execute();
}
VBA Code :-
Sub SetUserName()
Application.UserName = "Jeff Smith"
Dialogs(wdDialogToolsOptionsUserInfo).Display
End Sub
C# Code :-
public void SetUserName()
{
ThisApplication.Application.UserName = "Jeff Smith";
ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogToolsOptionsUserInfo].Display(ref missing);
}
VBA Code :-
Sub ShowRightIndent()
Dim dlgParagraph As Dialog
Set dlgParagraph = Dialogs(wdDialogFormatParagraph)
MsgBox "Right indent = " & dlgParagraph.RightIndent
End Sub
C# Code :-
public void ShowRightIndent()
{
Word.Dialog dlgParagraph = null;
dlgParagraph = ThisApplication.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatParagraph];
}
VBA Code :-
Sub ShowRightIndexForSelectedParagraph()
MsgBox Selection.ParagraphFormat.RightIndent
End Sub
C# Code :-
public void ShowRightIndexForSelectedParagraph()
{
ThisApplication.Selection.ParagraphFormat.RightIndent = 0.5f;
}
VBA Code :-
Sub SetKeepWithNextForSelectedParagraph()
Selection.ParagraphFormat.KeepWithNext = True
End Sub
C# Code :-
public void SetKeepWithNextForSelectedParagraph()
{
ThisApplication.Selection.ParagraphFormat.KeepWithNext = 1;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment