How to put a button on this class?

hello
i had a problem and i saw the comment of  Kevininstructor,and
i tested and i think this might help me
https://social.msdn.microsoft.com/Forums/vstudio/en-US/d14a09e9-9f12-48fd-bef5-914d976de7b9/save-a-file-automatically-by-code?forum=vbgeneral
does somebody know how to put a button on that class to execute it?
thank you

you are right armin
here is the code posted by Kevinisnstructor
'****************************** Module Header ******************************'
' Module Name: Solution2.vb
' Project: VBAutomateWord
' Copyright (c) Microsoft Corporation.
' Solution2.AutomateWord demonstrates automating Microsoft Word application
' by using Microsoft Word Primary Interop Assembly (PIA) and forcing a
' garbage collection as soon as the automation function is off the stack (at
' which point the Runtime Callable Wrapper (RCW) objects are no longer
' rooted) to clean up RCWs and release COM objects.
' This source is subject to the Microsoft Public License.
' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
' All other rights reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
#Region "Import directives"
Imports System.Reflection
Imports System.IO
Imports Word = Microsoft.Office.Interop.Word
#End Region
Class Solution2
Public Shared Sub AutomateWord()
AutomateWordImpl()
' Clean up the unmanaged Word COM resources by forcing a garbage
' collection as soon as the calling function is off the stack (at
' which point these objects are no longer rooted).
GC.Collect()
GC.WaitForPendingFinalizers()
' GC needs to be called twice in order to get the Finalizers called
' - the first time in, it simply makes a list of what is to be
' finalized, the second time in, it actually the finalizing. Only
' then will the object do its automatic ReleaseComObject.
GC.Collect()
GC.WaitForPendingFinalizers()
End Sub
Private Shared Sub AutomateWordImpl()
Try
' Create an instance of Microsoft Word and make it invisible.
Dim oWord As New Word.Application
oWord.Visible = False
Console.WriteLine("Word.Application is started")
' Create a new Document.
Dim oDoc As Word.Document = oWord.Documents.Add()
Console.WriteLine("A new document is created")
' Insert a paragraph.
Console.WriteLine("Insert a paragraph")
Dim oPara As Word.Paragraph = oDoc.Paragraphs.Add()
oPara.Range.Text = "Heading 1"
oPara.Range.Font.Bold = 1
oPara.Range.InsertParagraphAfter()
' Insert a table.
Console.WriteLine("Insert a table")
Dim oBookmarkRng As Word.Range = oDoc.Bookmarks.Item("\endofdoc").Range
Dim oTable As Word.Table = oDoc.Tables.Add(oBookmarkRng, 5, 2)
oTable.Range.ParagraphFormat.SpaceAfter = 6
For r As Integer = 1 To 5
For c As Integer = 1 To 2
oTable.Cell(r, c).Range.Text = "r" & r & "c" & c
Next
Next
' Change width of columns 1 & 2
oTable.Columns(1).Width = oWord.InchesToPoints(2)
oTable.Columns(2).Width = oWord.InchesToPoints(3)
' Save the document as a docx file and close it.
Console.WriteLine("Save and close the document")
Dim fileName As String = Path.GetDirectoryName( _
Assembly.GetExecutingAssembly().Location) & "\Sample2.docx"
oDoc.SaveAs(fileName, Word.WdSaveFormat.wdFormatXMLDocument)
oDoc.Close()
' Quit the Word application.
Console.WriteLine("Quit the Word application")
oWord.Quit(False)
Catch ex As Exception
Console.WriteLine("Solution2.AutomateWord throws the error: {0}", _
ex.Message)
End Try
End Sub
End Class

Similar Messages

  • APEX:How to put dynamic buttons in a Report.

    Hello all,
    I am creating one application in which i want two buttons in every record. I can't put it manually because it should change according to records in a table So Can anyone tell me how to put dynamic buttons in a report.
    Thanks & Regards,
    Jiten Pansara

    Hi Jiten,
    you cannot create buttons in the report, but you can always create link columns with some css class to show it as button.
    So in the both link column report attributes you will have class="button1" and class="button2"
    And in dynamic actions you need to bind the events based on your link column's jquery selector like:
    .button1
    .button2Thanks

  • How to put Skype button in adobe flash website

    how to put Skype button in adobe flash website. I got the code from "http://www.skype.com/intl/en-us/tell-a-friend/wiza​rd/" but unfortunately it can generate codes for only html websites and emails but my site is in flash and these codes are not working. Pls help me to put the Skype button on my flash website.

    Hi,
    Please refer to the following link Shopping Carts
    Regards,
    Aish

  • AS3 how to put the buttons always on top of the external swf in the code below?

    how to put the buttons always on top of the external swf in the code below?  I am  beginner use to as3, can someone help me?
    thanks, for all!!
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

    use:
    var Xpos:Number = 110;
    var Ypos:Number = 180;
    var swf:MovieClip;
    var loader:Loader = new Loader();
    var defaultSWF:URLRequest = new URLRequest("swfs/eyesClosed.swf");
    loader.load(defaultSWF);
    loader.x = Xpos;
    loader.y = Ypos;
    addChild(loader);
    // Btns Universal function
    function btnClick(event:MouseEvent):void {
    removeChild(loader);
    var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf");
    loader.load(newSWFRequest);
    loader.x = Xpos;
    loader.y = Ypos;
    addChildAt(loader,0);
    // Btn listeners
    eyesClosed.addEventListener(MouseEvent.CLICK, btnClick);
    stingray.addEventListener(MouseEvent.CLICK, btnClick);
    demon.addEventListener(MouseEvent.CLICK, btnClick);
    strongman.addEventListener(MouseEvent.CLICK, btnClick);

  • How to create a constructor for this class?

    Hi everybody!
    I have an applet which loads images from a database.
    i want to draw the images in a textarea, so i wrote an inner class, which extends textarea and overrides the paint method.
    but everytime i try to disply the applet in the browser this happens:
    java.lang.NoClassDefFoundError: WohnungSuchenApplet$Malfl�che
         at java.lang.Class.getDeclaredConstructors0(Native Method)
         at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
         at java.lang.Class.getConstructor0(Class.java:1762)
         at java.lang.Class.newInstance0(Class.java:276)
         at java.lang.Class.newInstance(Class.java:259)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
         at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
         at sun.applet.AppletPanel.run(AppletPanel.java:293)
         at java.lang.Thread.run(Thread.java:536)
    so my class has no own constructor, it just has the paint method overwritten.
    my class looks like this:
    public class Malfl�che extends javax.swing.JTextArea{
    public void paint(Graphics g){
    Color grey=new Color(220,220,220);
    g.drawImage(img,10,10,null);
    how should a constructor for this class look like?
    sorry i am quite new to this, so i really dont have a clue!
    my class does not have any attributes or requires any so it doesnt need a constructor, doesnt it?
    thanks a lot
    tim

    If you have no constructor you cant instanciate (I know i just murdered that spelling) the object.
    Malfl�che thisHereThingie = new Malfl�che()assuming that you want to run that class by itself you will need a main method that has the preceeding code in it. If you are running it from another class you need to instanciate it... but anyway at the very least for a constructor you need.
    public Malfl�che(){

  • How to put three button into one borders

    Hello:
    Please tell me how to set up a borders for multiple buttons.
    For example, I got six JButtons, their name are bOne, bTwo,bThree, bFour, bFive, bSix. I want a borders for
    bOne, bTwo,bThree, and another borders for bFour, bFive, bSix.
    Thanks
    *This program for add six Buttons on the JFrame
    import javax.swing.*;
    import java.awt.*;
    public class TestButton extends JFrame{
         private static TestButton tB;
         private static JButton jB;
         public static void main(String [] args){
              tB=new TestButton();
              tB.pack();
              tB.setVisible(true);
         public TestButton(){
              Container c=getContentPane();
              c.setLayout(new GridLayout(1,6));
              //add six buttons to frame
              jB=new JButton("Bone  ");
              jB.setBorder(null);
              c.add(jB);
              jB=new JButton("Btwo  ");
              jB.setBorder(null);
              c.add(jB);
              jB=new JButton("Btree  ");
              jB.setBorder(null);
              c.add(jB);
              jB=new JButton("Bfour  ");
              jB.setBorder(null);
              c.add(jB);
             jB=new JButton("Bfive  ");
             jB.setBorder(null);
              c.add(jB);
              jB=new JButton("Bsix");
              jB.setBorder(null);
              c.add(jB);
    }

    In case anybody cares.
    This individual asked this same question about tables 6 times
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421727
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421789
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421568
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421525
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421476
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421283
    then a question about buttons was asked 6 times
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421036
    http://forum.java.sun.com/thread.jsp?forum=57&thread=421013
    http://forum.java.sun.com/thread.jsp?forum=57&thread=420798
    http://forum.java.sun.com/thread.jsp?forum=57&thread=417624
    http://forum.java.sun.com/thread.jsp?forum=57&thread=417621
    http://forum.java.sun.com/thread.jsp?forum=57&thread=416510
    then a few miscellaneous question where asked:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=419990
    http://forum.java.sun.com/thread.jsp?forum=57&thread=419264
    http://forum.java.sun.com/thread.jsp?forum=57&thread=418945
    http://forum.java.sun.com/thread.jsp?forum=57&thread=418993
    http://forum.java.sun.com/thread.jsp?forum=57&thread=418418
    http://forum.java.sun.com/thread.jsp?forum=57&thread=416047
    Not once have they responded to thank the poster for their help. Not once have they even asked for claraification. All they do is start new threads asking the same question over and over and over.
    I know I'm not going to waste any more time answering these questions until the individual learns the proper use of a the forum. I hope others will do the same.

  • How to put ***.acquis.val for asset class (AUC &LAND)

    Dear All,
    According to I do lagacy data via AS91 (Asset Class: AUC & Land) I found that ***.acquis.val. field are gray.
    I defined Dep area = 0000 for both asset class because it must not calulate depreciation.
    Could anyone tell me how can I put acquisition value to these asset.
    Thank you in advance
    Best Regards,
    Utarat.P

    Hi,
    Please Check Cutover Date,
    Ex: If your Cut over date 31/03/2010, you are trying to post values in as91 @ 02/01/2010 system not allowed to give aqestion & Acc Dep values.
    Regards
    Viswa

  • How to put a button beside a selectOneChoice, mantaining the alignement

    Hi all,
    I am using Jdev 11.1.1.0.2.
    I have a panelFormLayout containing some selectOneChoice components.
    I'd like to put a a commandButton beside every selectOneChoice.
    I have tried to surrond the selectOneChoiceComponent and their associated button with a panelGroupLayout, but the selectOneChoice components are not aligned.
    Any ideas?
    Thanks
    Andry

    so what about this possibility:
    <?xml version='1.0' encoding='windows-1250'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
      <jsp:directive.page contentType="text/html;charset=windows-1250"/>
      <f:view>
        <af:document id="d1">
          <af:form id="f1">
            <af:panelGroupLayout id="pgl1" layout="horizontal">
              <af:panelFormLayout id="pfl1">
                <f:facet name="footer"/>
                <af:selectOneChoice label="Label 1thdfhfh" id="soc1">
                  <af:selectItem label="one" value="oneeeeeeeeeeeeeeee" id="si2"/>
                  <af:selectItem label="two" value="twooooo" id="si1"/>
                </af:selectOneChoice>
                <af:selectOneChoice label="Label 1" id="selectOneChoice1">
                  <af:selectItem label="one"
                                 value="oneeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" id="selectItem1"/>
                  <af:selectItem label="two" value="twioooooooooooooooooooooo" id="selectItem2"/>
                </af:selectOneChoice>
                <af:selectOneChoice label="Label 1555555555555555555555555555555555555" id="selectOneChoice2">
                  <af:selectItem label="oneeeeeeeeeeeeeeeeeeeeeeeeeeeee"
                                 value="oneeeeeeeeeeeeeeeeeeeeeeee" id="selectItem3"/>
                  <af:selectItem label="twooooooooooo" value="twio" id="selectItem4"/>
                </af:selectOneChoice>
              </af:panelFormLayout>
              <af:panelFormLayout id="pfl2">
                <f:facet name="footer"/>
                <af:commandButton text="commandButton 1" id="cb1"/>
                <af:commandButton text="commandButton 2" id="cb2"/>
                <af:commandButton text="commandButton 3" id="cb3"/>
              </af:panelFormLayout>
            </af:panelGroupLayout>
          </af:form>
        </af:document>
      </f:view>
    </jsp:root>

  • How to put radio buttons horizontally?

    Hi All,
       I am using RadioButtonGroupByKey.But its coming vertically.I want this to be displayed horizontally.Please help me soon.
    thanx
    anirudh

    Bind the RadioButtonGroupByKey.<i>selectedKey </i>property to a context attribute of type "string" (or DDIC simple type with valueset).
    You can either use the static valueset from the DDIC type or modify the valueset at runtime.
    To modify it, use code like
    IWDAttributeInfo info = wdContext.getNodeInfo().getAttribute("<name-of-attribute>");
    IModifiableSimpleValueSet valueSet = info.getModifiableSimpleType().getSVServices().getModifiableSimpleValueSet();
    valueSet.clear();
    valueSet.put("<key1>", "<value1>");
    valueSet.put("<key2>", "<value2>");
    valueSet.put("<key3>", "<value3>");
    Then you will get 3 radio buttons displaying "value1", "value2", "value3". Selecting a button will set the context attribute to the corresponding key.
    Set RadioButtonGroupByKey.<i>colCount </i>= 3 to get them in one row.
    Armin

  • How to put Download  button on Webdynpro ALV

    Hi,
    I used SELECT_OPTIONS     WDR_SELECT_OPTIONS as webdynrpo components  in my ALV report.I also need download option on the output.I am using just one main view to display the results.
    Also ,Output is always defaulting to 5 rows only.. Where can I change this default?
    Rgds
    Vara

    I'm a little confused because you talk about both Select-Options and ALV.  Which are you wanting to download and which is only dispaying 5 rows.  I'm going to assume that you mean the ALV and the mention of Select-Options is actually inmaterial.
    The ALV Component already has an export button built into it standard.  Were you looking for something else - and if so what kind of functionality did you want.
    To adjust the number of visible rows in the ALV use the configuration model interface that is exposed by the component usage: cl_salv_wd_config_table.. Here is an example. You will need to adjust the name of the component usage for the name you actually used.  I used ALV - then wd_this->wd_cpuse_alv. You would need to adjust this to wd_this->wd_cpuse_<your name> and wd_this->wd_cpifc_<your name>.
    DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage.
      l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
      ENDIF.
      DATA l_salv_wd_table TYPE REF TO iwci_salv_wd_table.
      l_salv_wd_table = wd_this->wd_cpifc_alv( ).
      DATA l_table TYPE REF TO cl_salv_wd_config_table.
      l_table = l_salv_wd_table->get_model( ).
      l_table->if_salv_wd_table_settings~SET_VISIBLE_ROW_COUNT( 20 ).

  • How to put iconic button in forms 10g?

    Hi All,
    I've created a button with iconic property set to yes and icon file set to open. in forms 10g
    But when I run the form, the button appeared without the open icon show!

    In webforms, you have to put your icons in a jar file and put the jar file in a directory where Java can read from. the easiest place to put the jar file is the %ORACLE_HOME%/forms/java directory found in your Oracle installation directory
    for instance if you have your devsuite installed in C:\devsuite10g put the jar file in C:\devsuite\forms\java.
    check out [url http://www.oracle.com/technology/products/forms/pdf/webicons.pdf]Webicons it has both detailed steps to deploy icons in webforms and an easy and fast way to do it.
    Tony

  • How to add stop button in this code AS3

    Hello, im new to this adobe flash AS3. i want to create a simple play sound using flash + XML file for wbesite., this is my code
    all this code are working greate.. but i have the problem to add stop_btn code my playlist button already have pause, prevous and next and play.. only stop button i have fail to create. this is my code
    var my_songs:XMLList;
    var my_total:Number;
    var my_sound:Sound;
    var my_channel:SoundChannel;
    var current_song:Number = 0;
    var song_position:Number;
    var song_paused:Boolean;
    var myXMLLoader:URLLoader = new URLLoader();
    myXMLLoader.load(new URLRequest("playlist2.xml"));
    myXMLLoader.addEventListener(Event.COMPLETE, processXML);
    function processXML (e:Event):void{
    var myXML:XML = new XML(e.target.data);
    my_songs = myXML.SONG;
    my_total = my_songs.length();
    function playSong(mySong:Number):void{
    var myTitle = my_songs[mySong].@TITLE;
    var myArtist = my_songs[mySong].@ARTIST;
    var myURL = my_songs[mySong].@URL;
    title_txt.text = myTitle;
    artist_txt.text = myArtist;
    if (my_channel){
    my_channel.stop();
    my_sound = new Sound();
    my_sound.load(new URLRequest(myURL));
    my_channel = my_sound.play();
    my_channel.addEventListener(Event.SOUND_COMPLETE, onNext);
    next_btn.addEventListener(MouseEvent.CLICK, onNext);
    function onNext(e:Event):void{
    current_song++;
    if (current_song>=my_total){
    current_song=0;
    playSong(current_song);
    prev_btn.addEventListener(MouseEvent.CLICK, onPrev);
    function onPrev(e:MouseEvent):void{
    current_song--;
    if (current_song<0){
    current_song = my_total-1;
    playSong(current_song);
    pause_btn.addEventListener(MouseEvent.CLICK, onPause);
    function onPause(e:MouseEvent):void{
    if (my_channel){
    song_position = my_channel.position;
    my_channel.stop();
    song_paused=true;
    play_btn.addEventListener(MouseEvent.CLICK, onPlay);
    function onPlay(e:MouseEvent):void{
    if (song_paused){
    my_channel = my_sound.play(song_position);
    song_paused=false;
    } else if (!my_channel){
    playSong(current_song);
    can some one help with me... thank you

    stop_btn.addEventListener(MouseEvent.CLICK, onStop);
    function onStop(e:MouseEvent):void{
       if (my_channel){
          my_channel.stop();

  • When I had IE9 I had "Print Friendly" button in my browser, I know they make it for Firefox also, but where is it and how do I put the button in my Toolbar?

    I went to the website and it said it downloaded, but when I click on the button in my Toolbar, nothing happens. I seen on a search engine that they make "Print Friendly" for Firefox now. Can you tell me where to find it, how to put the button in my Toolbar? I must be doing something or not doing something for it not to be working for me. I am not real computer friendly but I'm not a beginner either. So if you dont mind Please explain to me how to fix this issue in relatively easy step by step instructions. Thank you for your time, Sheybiker

    Is this what you are looking for? <br />
    http://www.printfriendly.com/browser_tool
    '''Click and Drag''' the Print Friendly button to your Bookmarks Toolbar.

  • How to add Refresh button

    Hello...
    This is my code. How to add REFRESH button in this code
    package sample.view;
    import javax.faces.event.ActionEvent;
    public class Student {
        public Student() {
            super();
        private String name;
        private String id;
        private String course;
        public void setName(String name) {
            this.name = name;
        public String getName() {
            return name;
        public void setId(String id) {
            this.id = id;
        public String getId() {
            return id;
        public void setCourse(String course) {
            this.course = course;
        public String getCourse() {
            return course;
        public void dosubmittoActionisterner() {
            // Add event code here...
            System.out.println(getName() + " " + getId() + " " + getCourse());
        public void dorefershActionlistener(ActionEvent actionEvent) {
            // Add event code here...

    Hi,
    is this a home work you are working on? Even as a student you should be able to express questions more clearly.
    Frank

  • How to create an object of a class?

    plz read the question carefully ..
    how to create the object of a class by giving the class name as an String
    suppose i have a java file name:" java1.java ".
    so now how to create an object of this class "java1"by passing a string "java1"..

    kajbj wrote:
    rajeev-usendi wrote:
    thanks but still i have problem..
    i have created the object but now i m unable to do anything with that created object..
    i have coded like this..
    Object o= Class.forName("java1").new Instance();
    after this i m unable to do anything with the object 'o'..So why did you create the instance? You can also get all methods using reflection, but that is probably not what you want to do. You should instead let the class implement an interface and cast the created object into that interface ans call the methods that you want to call.
    KajI agree with Kaj. If you need to use a class that's unavailable at compile time, you should create an appropriate interface by which to refer to the class and then you create instances reflectively and access them normally via their interface (which is called reflective instantiation with interface access)

Maybe you are looking for