Word 2010 VBA - Global Variables in VBA and using them in VBA Code

Hiya
I need some help.  I have the following code that takes a word document, converts it to pdf and saves it to the local temp folder and attaches it to an email.  Up until now the filename for the file has been hard coded.
I have now created a userform that allows the user to enter a filename for the document and I have created a global variable for the filename to be stored.
What I want to be able to do is pick up this filename from the global variable and add it to filepath in the code.  At the moment it just saves the document as Mytitle which is what the variable is called.
Here is my code, can I please have some help as I am a little lost, this is the first time I have created something so complicated!!
Public Mytitle As String
Private Sub CommandButton1_Click()
ConvertandSave
Createemailandattach
End Sub
Sub ConvertandSave()
'converts to pdf and save locally using filename from userform
ActiveDocument.ExportAsFixedFormat OutputFileName:="C:\temp\Mytitle.pdf", _
ExportFormat:=wdExportFormatPDF, OpenAfterExport:=True, OptimizeFor:= _
wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
BitmapMissingFonts:=True, UseISO19005_1:=False
End Sub
Sub Createemailandattach()
'creates email and attaches to the file
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.Mailitem
Dim MyFileName As String
On Error GoTo SendCancelled
MyFileName = "c:\temp\Mytitle.pdf"
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
    Set oOutlookApp = CreateObject("Outlook.Application")
End If
Set oItem = oOutlookApp.CreateItem(ofMailitem)
Set objRecip = oItem.Recipients.Add("   email address goes in here")
obj.Type = olTo
oItem.Display
'oItem.Subject = "My Profile - "& UCase(LastName) & " " & FirstName
oItem.Attachments.Add (MyFileName)
Exit Sub
SendCancelled
    MsgBox "This macro was cancelled"
End Sub
Any help here would be very much appreciated

Assuming that you have other code to set the value of Mytitle: change all instances of "c:\temp\Mytitle.pdf" to
"c:\temp\" & Mytitle & ".pdf"
Regards, Hans Vogelaar (http://www.eileenslounge.com)

Similar Messages

  • How declear global variable in form and use all form

    hi master,
    sir,
    how i declear global variable in form and how use this variable in all form
    i have year table and pik current year or date form table and move in global variable and use in all form
    please give ma idea
    thanking you
    Aamir

    Ok, so, what characterset was your database created with?
    Does that characterset have a representation of that character?
    -Mark

  • How to retrieve comments from one OfficeTask activity and use them in another OfficeTask activity for Multi level Approval sequential Workflow

    I'm designing a sequential site workflow using Visual Studio 2010 for Project Server 2010. In my case, I have following 6 stages in the workflow:
    1. InitialProposal Stage
    2. Approval Stage1 -- Needs approval from Approver Project Security Group Members1
    3. Rejection Stage
    4. Approval Stage2 -- Needs approval from Approver Project Security Group Members 2
    5. Execution Stage
    6. Completed Stage
    Requirement is workflow should move to Approval stage2 from Approval stage1  if approved by all members of Approver Project Security Group1and it should move to Rejection Stage even if a single member rejects it.
    Workflow should move from Approval Stage2 to Execution Stage if approved by all members of Approver Project Security Group2 and it should move back to Approval Stage1 on rejection by a single member of the group.
    I'm using inbuilt PSWApproval content type and OfficeTask activity for creating approval task for the group members at both stages.
    On task rejected in Approval stage2, task will be assigned again to Approval Stage1 and I want to show comments given by members of Approver Project Security Group2 to the members of Approver Project Security Group1 with this assigned task
    but I'm not able to retrieve comments from officeTask activity.
    My question is where exactly these comments are saved? how can we retrieve them and use them in another officetask activity? If this is not possible then what is the possible solution for meeting above mentioned business requirement?

    Hi Paul,
    Thanks for your suggestion.
    By comments field I'm assuming OfficeTask.Comments field. Problem is, this field is always null. I tried accessing this field in CheckExitCondition activity as well as in OnTaskCompleted but in both the cases, it was null only(I wrote comments while approving
    the task).
    I used a code activity within OnTaskCompleted activity and following code for accessing Comments and Description fields:
    public string officeComments;
            public string officeDescription;
            private void TaskCOmplete(object sender, EventArgs e)
                CodeActivity Sender = (CodeActivity)sender;
                Microsoft.Office.Workflow.Actions.OfficeTask ofctask1 = ((CompositeActivity)Sender.Parent).Parent as Microsoft.Office.Workflow.Actions.OfficeTask;
                officeComments = ofctask1.Comments;
                officeDescription = ofctask1.Description;          
    Please tell me if I'm doing anything wrong here, I'm very new to Workflows. Also, do I need to set any specific property of officeTask for retriving comments?
    Thank you

  • How to create RFQ s and use them to complete the program

    hi,
    how to create RFQ s and use them to complete the program
    thanks in advance

    Hi Santosh,
    RFQ is created through transaction ME41.
    You need to write down BDC for mass update of RFQ, because BAPI is not available.
    Regards,
    Tutun

  • External definition and used them as Data Type Templates

    hi all
    how to Develop external definition and used them as Data Type Templates .
    Thank u
    Swari

    HI
    External Definitions: If a definition of the message structure exists in wsdl, xsd, dtd formats, we can use it in the integration repository by importing it as an external definition.
    External Definations:
    An external definition enables you to import a local WSDL, XSD, or DTD file to the Integration Repository and specify which parts of the schema to extract as the description for a message. You can use these extracted message schema as:
    Output or input messages in message interfaces
    Source or target structures for message mappings
    There is a series of standard schema for describing the message structure at runtime. WSDL (Web Service Description Language), XSD (XML Schema Definition Language), or DTDs (Document Type Definitions) are often used to describe message schema. If a description of the message structure already exists in one of the above formats, you can use it in the Integration Repository by importing it as an external definition rather than re-entering it manually using the data type editor.
    Have a look at
    http://help.sap.com/saphelp_nw04/helpdata/en/43/ce49ef1019087ae10000000a1553f6/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/ba/d4c23b95c8466ce10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/26/9e97b0f525d743882936c2d6f375c7/content.htm
    cheers

  • This may sound like a stupid question,,,but can i downlaod other programmes to my ipad, and use them like i would on a pc/net book ?

    this may sound like a stupid question,,,but can i downlaod other programmes to my ipad, and use them like i would on a pc/net book ?

    No.
    It is not a replacement for a computer.
    It mirrors the selected content of your computer.
    The only programs that can be loaded on an ipad are those found in the app store.

  • Word 2010 table rendered reduced, upside down and backwards on conversion to pdf

    We have a Word 2010 document that includes a table, header and footer and a title paragraph with a border.
    When we convert this to pdf using Word's Acrobat -> Create PDF function, we get this (converting via Print -> Adobe PDF works fine however).
    Here is the above at 400% magnification.
    I thought I had seen all the curveballs Word 2010 and Adobe Pro X could throw but this is a new one on me. If anyone can tell me how or why the body of this document is reduced to illegibility, positioned at the top left corner of the page, upside down and backwards on pdf conversion I would be forever in their debt. (I have a couple of "accessibility experts" telling me this du to "odd code" and I would very much like to confirm that neither of them could find their own bottom with both hands.)

    I am assuming you did this with the Create PDF button. Give the print to the Adobe PDF printer a try and see if you get the same thing. You could also try the MS PDF plugin. MS has done some strange things in OFFICE 2007 and 2010 that cause heartburn for PDF creation. How much is an Acrobat issue, I am not sure -- probably a bit of an issue from both companies.

  • Word 2010 / Adobe PDFMaker Trial Mail Merge and ZWAdobeF, 1 PT Character

    Does anyone know why the Adobe Acrobat X PDMaker add-in for Word 2010 puts anin the front of the first merge field during a mail merge?  The merge works perfectly to create a .PDF, but I am a bit concerned that this will occur when we shell out some $$$ to use it to send 15,000 insurance cards to our student population.  The character is unprintable, and cannot be seen, but shifts the field over 1 pt everytime we merge.  If this happens 15,000 times our mail merge will not work.  Of course, the trial version of the software can only merge 1 record at a time.  Perhaps this is a not so sneaky way to stop trial users from actually using the software to send out 15,000 pieces for 'free'.  That would not be cool.

    Which version of Word 2010... 32bit or 64bit?
    Unless a recent update has fixed the problem(s) Acrobat is not fully compatible with Word 2010 64bit
    Acrobat X MS Office 2010 http://forums.adobe.com/thread/884628?tstart=0

  • Convert word 2010 TOC to pdf without numbering and hyperlink errors

    I made an automatic TOC (Table of Contents) for my Manual of procedures using the automatic creation under the Reference tab-create a table of contents. It looks great in word. I made sure the hyperlink is clicked in word as well. When I convert this document to pdf using adobe acrobat XI, the numbering of the TOC just changes to incorrect numbering. And the hyperlinks work only for a few initial pages only. I have 22 pages. Once converted, the TOC shows that I only have 16 pages and the linking is incorrect. How can I convert this and keep the numbering correct and also allow for the hyperlinks in the pdf document? Any help is appreciated. Thank you.
    -nisha

    Y.J. Lee wrote:
    I bought this product (Adobe XI pro) for the same purpose. After waisting many hours and digging through google and Adobe community, I learned it doesn't work, at least not for Mac. I HATE ADOBE!!!! GIVE MY MONEY BACK!
    This is a 15-20 year od bug in Acrobat. That Adobe refuse to fix. In this case they blame MS Office claiming they don't have the "proper hooks" for web Links. But it’s a red herring. The Mac Version of Office has the same exact hooks as the PC version. You can take a Mac version of the word file. Unopened on a PC and Drop on AcrobatPC and the links will appear. This has been proven by MS MVP's and employees. The defect is squarely with Acrobat and acrobat alone.
    You can have weblinks as long as they have been created with Office Auto-correct feature both http: 's and mailto: 's.  Go to Print menu > hold down PDF key until context menu apppears. Next choose adobe PDF. Now when first screen appears choose quality of PDF and whether to have Acrobat or reader Open immediately.   Click okay. Next screen  browse to desired save location. And you can alter the name. Click save. Tou links will appear and will be active.
    Another way which is easier  for one or two page PDF's:
    Save word file in .docx format.
    Now Dragthe file from save location and Drop on top of the Acrobat icon in the Dock.
    Wait for a few minutes while file is processed (it like using Distiller) You might be able to dring a couple of cups of tea or coffee while waiting.
    The the PDF will suddenly appear
    Save immediately.
    Now any links created by autocorrect will appear and be active.
    Both of these two methods only started working in Acrobat X, and XI so someone finally figured partially how to fix the 15 year old Problem

  • Blank Page appears after converting MS Word (2010 on Win 7) document to PDF using Adobe Acrobat XI

    Hi,
    Even after updating to the latest version of Adobe Acrobat Pro XI (11.0.2). While converting a MS Word 2010 .docx format document to .pdf, the cover page with text, image and background color, appears blank with only the background color.
    Apperciate if someone can give me a resolution for this issue.
    Best Regards

    The coverpage gets converted in Acrobat.com cloud service. Is Abobe going to fix this bug in the Acrobat XI version too?

  • Can I connect my 2 2010 imac's to each other and use one as a second display?

    I have 2 Imacs purchased in 2010.  Both have a mini display port on the back.  Can I connect them using a 2 male mini display cable and use the 2nd Imac as a 2nd display?

    Hi, if one of your iMac is a 27 inch one, you will be able to do it. see this article for further information: Target Display Mode: Frequently Asked Questions (FAQ) - Apple Support

  • CAN ONE HAVE THREE COPIES OF THE SAME DATABASE AND USE THEM ALTERNATLEY IN LIGHTROOM TO SEARCH FOR KEY WORDS, ETC?

    I have two back ups and a traveling copy of my work.  Each is 4 terabites and growing.  I want to apply keywords to he images in Lighroom, copy the new information to the other two drives which are backups and use any of the three in any of three computers.  The keywords are installed in all three computers, but how does the computer know it is a different hard drive without keying in all three hard drives.

    If each drive is set up exactly the same, with all image paths concurrent, you should be able to substitute the .lrcat with the newly keyworded info. into any one of them and that should bring in all info with a minimum of work. However, it does require diligence in keeping good track of which catalog is the "Master".

  • How to Declare Arrays in bpel and use them as acollection

    Hi,
    I Am new to Bpel, I had created an empty Bpel Process and configured file adapter to a directory, In my text file i have 3 records with four columns, each column seperated by ',' and each record seperated by "EOL(end of line)", Below is the xsd file generated by the native format xsd builder, taken a recieve activity to recieve the contents of file from file adapter.
    So all the data which is in the file will be there in recieve activity.
    FileContents
    55555,rgfdgsd,gfdgfdg,23
    66666,retretret,trtertg,21
    77777,rtrttreter,trtter,23
    My Question is
    I want to compare whether value of C1 = '55555' and if the value is equal to 55555 then that record with c1=55555 has to be inserted into database by using Arrays
    How to compare the value of c1 through bpel functions.
    with java i have to use the logic similar to this by using Xpath
    getElement by tagname(c1);- it will give all the elements with tagname c1, three records are there with tagname c1 (c1=55555,c1=66666,c1=77777), we have to iterate through the elemnts and check whether the value iof c1='55555' and get the whole parent block which contains values of c1,c2,c3,c4 and insert that to database
    What variables we have to use to get the Similar logic in bpel
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="http://TargetNamespace.com/FileAdapter"
    xmlns:tns="http://TargetNamespace.com/FileAdapter"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
    <xsd:element name="Associates">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Associate" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:double" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
    </xsd:element>
    <xsd:element name="C2" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
    </xsd:element>
    <xsd:element name="C3" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="," nxsd:quotedBy="&quot;">
    </xsd:element>
    <xsd:element name="C4" type="xsd:double" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    I want to do it by using Arrays,
    Please post the step by step procedure like
    How to declare an Array?
    How to iterate the results in recieve acticity of file adapter and put them to array?
    How to compare the values in array with our desired value?
    Please Look into this and suggest me the solution.
    Regards

    I think it is a good option to use transformations. Do you have any critical reason why you want to do this using array?
    Little explanation below for your questions.
    As per my understanding from variable is the recieve activity variable and to variable is the Array variable is it right?
    Yes. Here I was try to build my array from the different source system data. This will append data to the array variable.
    How can we declare an array variable in bpel(to variable) with name as Variable_Array, part as payload and query as ArrayList?
    *Any element that can hold another element can be a array.
    For example if element A is declared as sequence of element B type, then A acts as a array for B*
    Could you please explain this also, what is from variable? and what is to variable?
    +<assign name="Assign_XPath_For_Array">+
    +<copy><from expression="concat('/ns1:ArrayList/ns2:ArrayElem') "/><to variable="Variable_Xpath"/></copy>+
    +</assign>+
    what is the type of to variable "Variable_Xpath"(String or int etc)?
    This creates a dynamic Xpath and store in some variable here. Here the variable is called Variable_Xpath which is a string
    similarly what is the type of to variable?
    +<assign name="Assign_Read_Array">+
    +<copy>+
    +<from expression="bpws:getVariableData('Variable_Array','payload',bpws:getVariableData('Variable_Xpath'))"/>+
    +<to variable="Variable_Read_Array_Element" query="/ns1: ABC"/>+
    +</copy>+
    +</assign>+
    To variable type is the variable that I read from the Array.
    *For example if A is the array holding B, then the to variable is B and from is doing A[counter]*
    Every Little Helps
    Kalidass Mookkaiah
    http://oraclebpelindepth.blogspot.com/

  • Get Javascript values and use them in a servlet?

    Hey
    I have a HTML which has Javascript scripts which I have to get values from (a array to be exact) and pass them to a servlet so I can process the information in a certain way. I cant seem to find a way to do this properly as the servlet is server side and Javascript is client side. How can I implement this?
    Using a quick example example I have
    C:/index.html
    C:/js/script.js
    Index.html contains:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <script type="text/javascript" src="js/script.js">
    </script>
    </head>
    <body>
    a href="javascript:void(0);" id="add"><img src="images/menunew.png" alt="plus" border="0" />
    /a>
    </body>
    </html>
    Script.js contains:
    var Script = Class.create({
    a:4,
    b:5,
    add: function(){       
    return (this.a + this.b);
    (Ignore syntaxis errors as this is a quick example I wrote up just to see if you can give me a practical example on how to read it.)
    How can from a Java servlet access a and b from the script.js file (which contains a class named Script) and also access the function add which returns that value?
    Thank you for the help
    Edited by: 902756 on 16-dic-2011 0:18

    DrClap wrote:
    902756 wrote:
    1: Yes, it seems like the logically answer but Im not too up on AJAX and even less on mixing it up with servlets. Do you mind giving me a simple add (function) sample or something similar?You are looking at it the wrong way. What you actually want to do is to have the browser send a request (which somehow contains that Javascript data) to a URL which causes the servlet to receive the data. There's no "mixing it up" going on there. The client and the server are entirely separate.
    And since that request would be an HTTP request, it's just text. There's no concept in HTTP of transmitting objects, whether they be Javascript objects or Java objects. Anything you want to transmit has to be converted into text by the sender and converted back into objects by the receiver.
    So there's no such thing as "a simple add function". You're going to have to stop thinking in that way and start thinking of client-server systems in the way they actually are.The thing is I want to start simple to grab a simple concept....
    Im trying a AJAX route and I have the following:
    /index.html
    /js/Adding.js
    Index contains:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
         <title></title>
         <script type="text/javascript" src="js/Adding.js"></script>
    </head>
    <body>
    <select name="num1">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    </select>
    <select name="num2">
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    </select>
    <form method="get" name="adding">
    Do
    <span id="res"></span>
    </form>
    </body>
    </html>
    Adding.js contains
    var Adding = Class.create({
    x: null,
    y: null,
    add: function()
         var xmlHttp = new XMLHttpRequest();
         var value1 = document.getElementById("num1").value;
    var value2 = document.getElementById("num2").value;
         xmlHttp.open("GET", "index.html", false);
         xmlHttp.send(value1 + value2);
         var result = document.getElementById("res");
         result.innerHTML = xmlHttp.responseText;
    This shows 2 comboboxes full of numbers and link saying "Do" which calls the javascript function and adds the two numbers in the comboboxs and shows them on the screen without refreshing the page. This does not work and I would like this to work before I continue onto the bigger picture.

  • Reading values from JTextField and using them?

    Hello,
    I am trying to make a login screen to connect to an oracle database. Im pretty new to creaing GUI. I need help with reading the values from the JTextField and to be able to use them for my connection. So do I need to apply a listener? How do I go about doing that in this project. Thanks for any code or advice.
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.sql.*;
    public class UserDialog
        String databaseURL;
        String driver;
        String database;
        String username;
        String password;
        String hostname;
        String port;
        UserDialog() {
            getInfo();
        static String[] ConnectOptionNames = { "Login", "Cancel" };
        static String   ConnectTitle = "Login screen";
        public void getInfo() {
            JPanel      connectionPanel;
            JLabel     databaseURLLabel = new JLabel("Database URL:   ", JLabel.LEFT);
         JTextField databaseURLField = new JTextField("");
         JLabel     driverLabel = new JLabel("Driver:   ", JLabel.LEFT);
         JTextField driverField = new JTextField("");
            JLabel     databaseLabel = new JLabel("Database:   ", JLabel.LEFT);
         JTextField databaseField = new JTextField("");
            JLabel     usernameLabel = new JLabel("User Name:   ", JLabel.LEFT);
         JTextField usernameField = new JTextField("");
            JLabel     passwordLabel = new JLabel("Password:   ", JLabel.LEFT);
         JTextField passwordField = new JPasswordField("");
            JLabel     hostnameLabel = new JLabel("Host Name:   ", JLabel.LEFT);
         JTextField hostnameField = new JTextField("");
            JLabel     portLabel = new JLabel("Port:   ", JLabel.LEFT);
         JTextField portField = new JTextField("");
         connectionPanel = new JPanel(false);
         connectionPanel.setLayout(new BoxLayout(connectionPanel,
                                  BoxLayout.X_AXIS));
         JPanel namePanel = new JPanel(false);
         namePanel.setLayout(new GridLayout(0, 1));
         namePanel.add(databaseURLLabel);
         namePanel.add(driverLabel);
            namePanel.add(databaseLabel);
            namePanel.add(usernameLabel);
            namePanel.add(passwordLabel);
            namePanel.add(hostnameLabel);
            namePanel.add(portLabel);
         JPanel fieldPanel = new JPanel(false);
         fieldPanel.setLayout(new GridLayout(0, 1));
         fieldPanel.add(databaseURLField);
            fieldPanel.add(driverField);
            fieldPanel.add(databaseField);
            fieldPanel.add(usernameField);
         fieldPanel.add(passwordField);
            fieldPanel.add(hostnameField);
            fieldPanel.add(portField);
         connectionPanel.add(namePanel);
         connectionPanel.add(fieldPanel);
            // Connect or quit
            databaseURL = databaseURLField.getText();
            driver = driverField.getText();
            database = databaseField.getText();
            username = usernameField.getText();
            password = passwordField.getText();
            hostname = hostnameField.getText();
            port = portField.getText();
            int n = JOptionPane.showOptionDialog(null, connectionPanel,
                                            ConnectTitle,
                                            JOptionPane.OK_CANCEL_OPTION,
                                            JOptionPane.PLAIN_MESSAGE,
                                            null, ConnectOptionNames,
                                            ConnectOptionNames[0]);
            if (n == 0) {
                System.out.println("Attempting login: " + username);
                String url = databaseURL+hostname+":"+port+":"+database;
             // load the JDBC driver for Oracle
             try{
                   DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
                   Connection con =  DriverManager.getConnection (url, username, password);
                System.out.println("Congratulations! You are connected successfully.");
                con.close();
                System.out.println("Connection is closed successfully.");
             catch(SQLException e){
                System.out.println("Error: "+e);
            else if (n == 1)
                    System.exit(0);
        public static void main (String args []) {
             UserDialog ud = new UserDialog();
    }thanks again,
    James

    the reason why you can't get the text is because you are reading the value before some actually inserts anything in any fields.
    Here is what you need to do:
    Create a JDialog/JFrame. Create a JPanel and set that panel as contentPane (dialog.setContentPane(panel)). Insert all the components, ie JLabels and JTextFields. Add two buttons, Login and Cancel to the panel as well. Now get the username and password field values using getText() inside the ActionListener of the Login.
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class LoginDialog extends JDialog
    String username, password;
      public LoginDialog( ){
        setTitle( "Login" );
        JPanel content = new JPanel(new GridLayout(0, 2) ); // as many rows, but only 2 columns.
        content.add( new JLabel( "User Name" ) );
        final JTextField nameField = new JTextField( "" );
        content.add( nameField );
        content.add( new JLabel( "Password" ) );
        final JTextField passField = new JTextField( "" );
        content.add( passField );
        JButton login = new JButton( "Login" );
        login.addActionListener( new ActionListener(){
          public void actionPerformed( ActionEvent ae ){
            username = nameField.getText();
            password = passField.getText();
            // call a method or write the code to verify the username and login here...
        content.add( login );
        JButton cancel = new JButton( "Cancel" );
        cancel.addActionListener( new ActionListener( ){
          public void actionPerformed( ActionEvent ae ){
            dispose(); // close the window or write any code that you want here.
        content.add( cancel );
        pack( ); // pack everything in the dialog for display.
        show(); // show the dialog.

Maybe you are looking for

  • SB Audigy 1 : Loudness of audio-outputs adjustabl

    Hi is it possible to get the second output (black) as loud as the first one (green) ? I can make the front output as quiet as the second one in the surround mixer but there seems to be a max loudness level so i cant make it other way around. anybody

  • Does Hyperion/Essbase add-in works with Excel 2010?

    Is this possibility and is performance enhanced/reduced? Thanks.

  • Linked list error

    Can anyone tell what's wrong with the following code? It says arguments(int) is not supported, but I don't know what it means. Thank you. import java.util.*; public class tester {       * @param args      public static void main(String[] args) {     

  • Hp g72 b60us keyboard

    I have purchased a replacement keyboard for my hp G72 b60us laptop and need instructions on how to install it.

  • Import to iTunes

    Can you import a DVD movie like a cd on iTunes acc.