To Run a Word Macro recorded in 2000 in latest versions of Word

Hello All,
I have recorded a macro in word 2000 and calling that macro through Jacob 1.11 in my Java Swing application. That works fine for word 2000. I just want to use that same macro in Word Xp and for latest versions of Word. The problem is it is not invoking the macro in Word XP. But internally it is functionaning. I want to open it whenever the Word is opened.
I have placed the macro other than in Normal.dot file and trying to open it. It opens in word 2000 as i said but not in XP and latest versions. Please refer the following code and help me....
thanks in advance
import java.io.File;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
public class WordEventTest
     public WordEventTest()
               try
                    File wordFileName = new File("C:"+File.separator+"example5.rtf");
               String strWordFile = wordFileName.toString();
                    String secondFile = "C:" + File.separator+"example1.rtf";
                    ActiveXComponent wordDocuments = new ActiveXComponent("Word.Application");
                    wordDocuments.setProperty("Visible", new Variant(true));
                    Dispatch documents = Dispatch.get(wordDocuments, "Documents").toDispatch();
                    Dispatch openDocuments = Dispatch.call(documents, "Open", new Variant(strWordFile)).toDispatch();
                    Dispatch.call(openDocuments, "SaveAs", new Variant(secondFile), new Variant(6));
                    wordDocuments.setProperty("Visible", new Variant(false));
                    Dispatch copiedDocument = Dispatch.call(documents, "Open", new Variant(secondFile)).toDispatch();
                    Dispatch.call(wordDocuments, "Run", new Variant("iMedXGrading.NewMacros.Grading"));
                    Dispatch oldDocuments = Dispatch.call(documents, "Open", new Variant(secondFile)).toDispatch();
               }catch(Exception e)
                    e.printStackTrace();
     public static void main(String args[])
          WordEventTest wordTest = new WordEventTest();
}

Hi All,
While doing the same I am facing an issue.
Actually I am getting the exception
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: Documents
Description: An unknown COM error has occured.
     at com.jacob.com.Dispatch.invokev(Native Method)
     at com.jacob.com.Dispatch.get(Dispatch.java)
     at WordEventTest.<init>(WordEventTest.java:24)
     at WordEventTest.main(WordEventTest.java:47)
where line 24 marked as"Dispatch documents = Dispatch.get(wordDocuments, "Documents").toDispatch();"
and the line 47 is as"WordEventTest wordTest = new WordEventTest();"
any suggestion to remove the exception.
Thanks
Kushagra

Similar Messages

  • Can't Figure Out If My Macbook Can Upgrade , currently running 10.6.8 and wanted to get latest version os but can't upgrade current os Please Help !!!!

    Can't Figure Out If My Macbook Can Upgrade , currently running 10.6.8 and wanted to get latest version os but can't upgrade current os Please Help !!!! Hardware Overview:
      Model Name: MacBook Air
      Model Identifier: MacBookAir3,1
      Processor Name: Intel Core 2 Duo
      Processor Speed: 1.4 GHz
      Number of Processors: 1
      Total Number of Cores: 2
      L2 Cache: 3 MB
      Memory: 2 GB
      Bus Speed: 800 MHz
      Boot ROM Version: MBA31.0061.B01
      SMC Version (system): 1.67f4
      Serial Number (system): C0*******DQX
    processor 1.4 ghz
    mem 2gb 1067 mhz ddr3
    startup disk Macintosh HD
    <Edited by Host>

    You can upgrade to Mountain Lion
    Upgrading from Snow Leopard to Mountain Lion
    You can upgrade to Mountain Lion from Lion or directly from Snow Leopard. Mountain Lion can be downloaded from the Mac App Store for $19.99.
    If you sign into the App Store and try to purchase Mountain Lion but the App Store says your computer is not compatible then you may still be able to upgrade to Lion per the following information.
    Upgrading to Mountain Lion
    To upgrade to Mountain Lion you must have Snow Leopard 10.6.8 or Lion installed. Purchase and download Mountain Lion from the App Store. Sign in using your Apple ID. Mountain Lion is $19.99 plus tax. The file is quite large, over 4 GBs, so allow some time to download. It would be preferable to use Ethernet because it is nearly four times faster than wireless.
         OS X Mountain Lion - System Requirements
           Macs that can be upgraded to OS X Mountain Lion
             1. iMac (Mid 2007 or newer) - Model Identifier 7,1 or later
             2. MacBook (Late 2008 Aluminum, or Early 2009 or newer) - Model Identifier 5,1 or later
             3. MacBook Pro (Mid/Late 2007 or newer) - Model Identifier 3,1 or later
             4. MacBook Air (Late 2008 or newer) - Model Identifier 2,1 or later
             5. Mac mini (Early 2009 or newer) - Model Identifier 3,1 or later
             6. Mac Pro (Early 2008 or newer) - Model Identifier 3,1 or later
             7. Xserve (Early 2009) - Model Identifier 3,1 or later
    To find the model identifier open System Profiler in the Utilities folder. It's displayed in the panel on the right.
         Are my applications compatible?
             See App Compatibility Table - RoaringApps.
         For a complete How-To introduction from Apple see Upgrade to OS X Mountain Lion.

  • I get aq run time error when trying to load the latest version of iTunes. Help.

    I get a run time error when attempting to install the latest version of iTunes & now cannot access iTunes. Can anyone help me?

    Hi jalbany,
    Thanks for using Apple Support Communities.  This article has steps you can take for the error you're seeing:
    iTunes 11.1.4 for Windows: Unable to install or open
    http://support.apple.com/kb/TS5376
    Cheers,
    - Ari

  • Is iSight camera recording disabled on the latest version of iMovie for Mavericks?

    Using the latest version of iMovie for Mavericks, can we record directly from iSight camera, or the software only allows videos imported from HD Cameras and PhotoBooth?

    Use the import button.

  • My new PC runs WIn.8.1 plus,..Will the latest version of Quick Time work for me?

    I have a recent PC running Windows8.1plus, ..what version of Quick Time do I need?..Will it work?

    Hi robertfromsalt spring island,
    Happy Holidays!
    The resource below will explain how to uninstall and re-install Quicktime for Windows if you are having issues with the software.
    iTunes 10.5 or later for Windows: Older media files may require QuickTime - Apple Support
    http://support.apple.com/en-is/HT203459
    With iTunes 10.5 or later, QuickTime isn't included when you install iTunes. Although media content purchased or rented from the iTunes Store doesn't need QuickTime to play, you may have older media files that require QuickTime. 
    Install QuickTime
    If you already have QuickTime installed, you may have to uninstall and reinstall QuickTime.
    Download QuickTime.
    Double-click the downloaded file.
    Follow the directions in the QuickTime Installer to complete the installation.
    Uninstall QuickTime on Windows Vista, Windows 7, and Windows 8
    Quit QuickTime if it's open.
    From the Start menu, click Control Panel.
    In Control Panel, click "Uninstall a program." The Programs and Features Control Panel will open.
    If you don't see the "Uninstall a program" link, click Programs and Features.
    Select QuickTime from the list of currently installed programs and click Uninstall.
    When asked if you would like to remove QuickTime, click Yes.
    Restart your computer.
    I hope this information helps ....
    - Judy

  • When I open Firefox, I get a message saying my INSTALLED version is more than a few months old, and I need to upgrade. But when I check for updates, there are none. I run v. 3.6.13 Mac, the latest version. Does it want me to install the beta v4 or what?

    This message appeared in the last 2 weeks. I was traveling and using a variety of internet portals. But it's still appearing now that I'm home, so that probably is not a factor. I have Firefox set for auto download/install of updates.

    Firefox 3.6.16 has a newer build and release date than Firefox 4.0 does.

  • How to run a VB macros code on Query refresh?

    Hi BW gurus,
    Please help me out with this task.
    I have a macros as below
    <b>Sub Table_To_Cons()
        'Copy the occupied rows
        Application.DisplayAlerts = False
        TargetSheet = ActiveSheet.Name
        Sheets("Table").Activate
        j = 2
        For i = 21 To 65536
            If Range("F" & i).Value = "" Then
                'MsgBox "The Cell is Empty"
            Else
                f = Range("F" & i).Value
                g = Range("G" & i).Value
                Sheets("Consolidated Data").Range("A" & j).Value = f
                Sheets("Consolidated Data").Range("B" & j).Value = g
                j = j + 1
            End If
        Next
        Sheets("Consolidated Data").Activate
        MsgBox "Finished"
        ' Update Chart
        Sheets("Chart1").Select
        ActiveChart.PlotArea.Select
        ActiveChart.SetSourceData Source:=Sheets("Consolidated Data").Range("A2:B6") _
            , PlotBy:=xlRows
    End Sub</b>
    User are not interested to run the VB macros manually.
    Instead they are asking like this.The macros should run and show the latest result everytime when we refresh the query.
    Can someone help me out how to achieve this.
    Any kind of help is appreciated.
    Thanks in Advance
    Have a nice day
    Regards
    Sam Mathew

    Hi Sam,
    Very interesting that the Properties dialog has changed.  I have no experience with NW2004s.  I will answer your questions based on what I do have experience with; then, we will need to do some testing to check my assumptions.
    Your first question: does this subroutine already exists in a workbook, or do we have to manually type it in?  In the days before Excel 2002, the answer was "yes", the subroutine already exists.  Since Excel 2002, the answer is maybe.  More often than not, "no" ... and you have to type it in.
    But, whether it exists or not, you will find out when I answer yoru second question:  exactly where should I search for it?  Since you have written a macro, you already know about the Visual Basic Editor (VBE).  Since I am not sure how much you know about the VBE, I will explain it as if you know nothing.  Please do not be offended.
    As a general orientation to the Visual Basic Editor (VBE), there are 4 Windows you want to become familiar with:
    1.     the Project Explorer Window;
    2.     the Properties Window;
    3.     the Object Browser Window; and,
    4.     the Code Window.
    You should see the Project Explorer window on the left side of the VBE.  If it is not already visible, make it visible in one of 3 ways:
    i.     use the VBE menu bar and select View >> Project Explorer
    ii.     use shortcut keys Ctrl+R
    iii.     use the VBE Standard toolbar and select the icon for Project Explorer
    In the Project Explorer window you can all of the "Projects" (workbooks and add-ins), that are loaded. 
    In the view of your workbook (the one with the macro) there are at least twol groups of "objects" shown:
    •     Microsoft Excel Objects (these are Worksheets and Workbooks)
    •     Modules (I call these "General Code Modules")
    There are two other possible types of objects:
    +  Forms
    +  Class Modules
    Visual Basic Code is always written in a Code Window.  There are 3 types of code windows:
    i.     Object Code Windows
    ii.     General Code Modules
    iii.     Class Modules
    When you use the Excel macro recorder, it always creates the macro in a General Code Module.  The subroutine SAPBEXonRefresh also will be in a General Code Module. 
    To find it (if it exists), you can start in any code module in your workbook, press Ctrl+F, enter SAPBEXonRefresh, click the radio button to Search in Current Project.
    Now, to test my assumptions ... while you are in the Visual Basic Editor, with the Project Explorer Window open, please look under Microsoft Excel Objects and see if there is an object named "SAPBEXqueries".  If not, stop right there.  I cannot help you.
    If the SAPBEXqueries object is there, let me explain what it is.  This is a worksheet that is VERY hidden.  That means, it is hidden so that it cannot be made visible from Excel.  It can only be made visible from the VBE.  Let's do not now.
    Select the SAPBEXqueries object (double-click), then open the Properties window in the VBE.
    You can open the properties window using:
    +  View Properties Window
    +  press F4
    +  use the standard toolbar and click the Properties icon
    Look at the Visible property.  It should 2 - Very Hidden.  Change it to Visible.  Now switch back to the Excel view.  Look in cell F4.  What do you see in this cell?  It should be:  SAPBEXq0001, or something very similar to that.
    Now (still in Excel) open the GoTo dialog (Edit >> Go To; or, press F5).  This will list all of the Named Ranges in the workbook.  If you are on the SAPBEXqueries worksheet, the GoTo dialog should list a number of Named Ranges starting with SAPBEXq000,,,,,  Do you see this?
    I am very interested to learn what you see when you do these things.  And, I am very willing to answer any questions you have as a result of doing this testing.
    By the way, when you make the SAPBEXqueries worksheet hidden again, be careful.  As soon as you make it hidden (or very hidden), the selection in VBE will change to an object that is NOT hidden.  So, if you are not watching carefully, you might think that you are still on the SAPBEXqueries sheet and that you failed to hide it.  And, pretty soon, if you are not careful, you will have hidden every worksheet in the workbook!
    - Pete

  • Does Flex Builder 3 have a macro recorder?

    I tried an Eclipse add-in called MacroSchmacro but it does
    not seem to function in FB3. Does anyone know of a macro-recorder
    add-in or Eclipse based editor that has macro functionality the
    will work with FB3? I know there are many stand-alone editors but
    would like to keep it in the development environment.

    I settled for Notepad++, swapping between the two editors and
    running the macro in Notepad++ is not all that much trouble. On the
    other hand, FB should have this feature built-in or at least as an
    add-in. @Greg: The only add-in I found was MacroSchmacro, doesn't
    seem to work in the FB version of Eclipse though.

  • ERROR while running workbook with macros

    Hi all
    I am running a workbook which has macros in it and thus some buttons for different functions.
    Whenever i click on a particular button which should give a new selection window, it is giving me an error as follows:-
    " Microsoft Office Excel has encountered a problem and needs to close.  We are sorry for the inconvenience."
    Please help me out to resolve this issue.
    Any help would be grateful.
    Thanks,
    Vikrant Mahajan

    Hi Vikrant,
    You can check any of the below options. Hope it helps :
    -  Check if you have not opened any other excel in the background .
    -  Check Excel security settings and Macros settings via Office Button -> Excel Options -> Trust Center ->
        Trust Center Settings-> Macro Settings
    -  Also try installing updated version of the MSExcel 2007 BI ADD-ON Patch and enable tha Macros.
    -  Update GUI patch.
    Regards,
    Akanksha

  • Just found out that I can't run microsoft word or adobe photo shop with Mavericks, any way to solve this?

    Just found out that I can't run microsoft word or adobe photo shop with Mavericks, is there a way to make this work?

    You must be using very old versions (Office 2004 or older, Photoshop CS2 or older).
    Upgrade to newer, or current versions.

  • How can I run microsfot Word on my mac?

    Just wondering how I could get and run microsoft word on my mac!
    Thanks

    Office 2004 does not work on Lion. You need 2011 or 2008.
    2004 is a PowerPC application and they are no longer supported on Lion.

  • Run MS Word on my Verizon iPhone 4

    I have looked for an app which I can use to run MS Word.  Is there one available?

    No. You can't run MS Word. Word is a product for PC's and Macs. There are lots of office apps out there for the iPhone. Documents to Go, and Pages are just a few. Look in the app store under productivity.

  • Will Mountain Lion run microsoft word?

    Will Mountain Lion run Microsoft Word?

    Yes, all versions of Microsoft Office (Word, Excel, PowerPoint & Outlook) are compatible with OS X.  Update to the latest versions of OS X & Office.  Office updates are released frequently so be sure to keep it up-to-date
    Cheers !

  • I'm running OSX 10.8.5 Mountain Lion.  What version of QuarkXpress and Microsoft Word run with this level?

    I'm running OSX 10.8.5 Mountain Lion.  What version of QuarkXpress and Microsoft Word run with this level? My older versions are no longer supported.

    Hi Jrehoboth,
    please see here: http://forums.quark.com/viewtopic.php?f=14&t=4608
    At the bottom of the post we summarized which version you can run on each version of OS X:
    So if your operating system is OS X Mountain Lion (10.8) then you can use QuarkXPress 9 & QuarkXPress 10 and soon QuarkXPress 2015.
    Thanks
    Matthias

  • After I covered 250 miles I got the automated congratualtions, but now after every run I get the recorded message again saying I just covered another 250 miles. Can I reset or stop it without completly resetting everything?

    I run with the Nano and shoe sensor. After I covered 250 miles I got the automated congratualtions, but now after every run I get the recorded message again saying I just covered another 250 miles. Can I reset or stop it without completly resetting everything?

    Same issue here.  This is really disappointing.  I used to look forward to the milestone messages after each run, especially when I was surprised by a celebrity voice.  Now, it's the same thing every single time, "Congratulations on another 250 miles.  Way to go!" or something along those lines.  I was proud of the 250 mile mark, but please...I don't want to hear it every time! 
    I hope there's some movement on this issue.
    ~ Heather

Maybe you are looking for

  • Procedure to delete base on a date

    I'm trying to create a procedure to delete all the rows that are < than the date received by parameter. Need some help since I'm not sure how can I compare the dates, in the table the field is defined as date also the param that I'm receiving. After

  • Encoding as Bluray and Standard DVD on the same project?

    If I have a project in HD and want to make additional DVDs with standard DVD , can i use the same project?  I dont want to have to remake all the menus and links. Thanks, John Q. 

  • Passing array of parameters to constructor

    I'm writing a script which facilitates interaction between javascript and an already existing flash library. One of the things I need to do is create an instance of class x, where class x can be one of a large number of classes. The constructors for

  • Conditional build tags applied to topic but it still displays in my TOC?

    I have applied topic level conditional build tags to topics. The corresponding books are still being displayed in my TOC. I checked the 4 topics and the condition is applied at the topic level. What am I missing here?

  • Lightweight photo management app?

    Hello, I have a large collection of photos (>20GB), so a way to manage them is essential and directories aren't good enough. I need good search by tags and EXIF. However, I'd like a simple, lightweight tool to do that. I've been through - digiKam (to