MS-Word Macros with paramers via OLE

Hi,
This is probably more of an MS-Word question than a Forte question,
but somebody out there might have done this before...
I have some MS Word macros (Originally WordBasic, but recently they
underwent automatic conversion to become Visual Basic) which take
parameters.
I used to call these macros from Forte using DDE.
These days, it's a lot more fashionable to use OLE automation than
DDE so I thought I'd give that a go.
But I can't.
Word.Applicaiton has a Run() method to run macros, but not macros
with parameters. Is there a neat way of getting macro parameters
across to Word?
- Ed.
Eduard E Havelaar | For the foolishness of God is wiser
Information Services Section | than man's wisdom, and the weakness
University of Canterbury | of God stronger than man's strength
Christchurch, New Zealand | - I Cor 1:25

have a look at this here article:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

Similar Messages

  • Re: MS-Word Macros with paramers via OLE

    I did this using an intermediette file. I wrote into a file from Forte, and
    used the Macro to read the file and replace the Variables in my Word Document
    using these values in the file.
    Hope this helps.
    Venkat Kodumudi
    Price Waterhouse LLP
    Internet: [email protected]
    Internet2: [email protected]

    Hi Adriane,
    Please search this forum using keywords VBA and Tutorial. You don't have to work through the entire tutorial, but should at least have a look at the section explaining the Object Browser. The Object Browser is the easiest way for you to examine the object model for applications that support OLE automation. The knowledge gained by examining an app's object model is not documentation, exactly, but often provides the important information (syntax, argument values) that a developer wants to know.
    If VBA Help (an Office feature) is installed, pressing <F1> while an element is selected within the Object Browser, will take you to formal documentation for the object model of most Office apps.
    I do recommend taking the time to work through the full tutorial, as I have written it, in hopes that developers will see the similarity between VBA code and equivalent OLE2 code, and how much easier it is to hammer out VBA code (thanks to code completion.) As I mention in the tutorial, I do all prototyping and debugging in VBA. Once the VBA code runs satisfactorily, I port it to OLE2. It sounds like extra work, but once you've seen how quickly you can code and debug VBA code, it doesn't make sense to torture yourself trying to do all this on the OLE2 side.
    Hope this helps,
    Eric Adamson
    Lansing, Michigan

  • Launch Microsoft Word macro with an applet

    Hi,
    I've got the following problem :
    First, I'd like to generate a .txt file (from an applet) on the client PC with informations (name, address...)
    Second, I'd like to lauch word macro from the applet and to merge informations from the .txt file with the .doc.
    Is it possible to do that ?
    Is it the best solution ? (the goal of the application is to generate letter to send to client)
    Thank You
    Sophie

    You can do it via Applet Servlet Communication.

  • Office control ms_word - runmacro, calling a macro with parameters

    How can I call word macro with parameters?
    I have ms word document with macro, for example:
    Sub Makro1(ByVal bookmark As String, ByVal text As String)
    ' Makro1 Makro
        Selection.GoTo What:=wdGoToBookmark, Name:=bookmark
        Selection.TypeText text:=text
        ActiveDocument.Bookmarks(bookmark).Delete
    End Sub
    I try call this macro from webdynpro:
      TRY.
          CALL METHOD
    wd_this->document->IF_IOS_APPLICATIONPROPERTIES~RUNMACRO
            EXPORTING
              NAME             = 'Makro1("z1","test")'
              ERRORINFORMATION = co_error_getcontent_stru
       IMPORTING
         RESULT           =
        CATCH CX_IOS_APPLICATIONPROPERTIES .
        CATCH CX_IOS_COMMUNICATIONWRAPPER .
        CATCH CX_IOS_ENVIRONMENT .
      ENDTRY.
    This macro cannot call. )
    Calling a macro without parameters is ok.
    Sub Makro2()
    Call Makro1("z1", "test")
    End Sub
          CALL METHOD
    wd_this->document->IF_IOS_APPLICATIONPROPERTIES~RUNMACRO
            EXPORTING
              NAME             = 'Makro2'
              ERRORINFORMATION = co_error_getcontent_stru
       IMPORTING
         RESULT           =
    Greats Radek

    1. Yes. Download from some location as binary file.
    2. Unzip by class CL_ABAP_ZIP. For filling bookmarks i need file 'word/document.xml'.
      CL_ABAP_ZIP->GET
    Unzipped files are only in memory.
    3. For parsing and filling bookmarks i use classes and interfaces cl_ixml, if_ixml*
    * create a DOM from the xstring
      lr_ixml = cl_ixml=>create( ).
      lr_stream_factory = lr_ixml->create_stream_factory( ).
      lr_istream  = lr_stream_factory->create_istream_xstring( iv_docx ).
      lr_document = lr_ixml->create_document( ).
      gr_document = lr_document.
      lr_parser = lr_ixml->create_parser( document       = lr_document
                                          istream        = lr_istream
                                          stream_factory = lr_stream_factory ).
      CALL METHOD LR_PARSER->ADD_PRESERVE_SPACE_ELEMENT
        RECEIVING
          RVAL   = lv_rval.
      IF lv_rval <> abap_true.
    * Err in parser XML
      ENDIF.
    CALL METHOD LR_PARSER->SET_XML_SPACE_AWARE.
    IF lv_rval <> abap_true.
    * Err in parser XML
    ENDIF.
    * Finding and filling bookmarks
      lr_root     = gr_document->get_root_element( ).
    * All elements "w:bookmarkStart"
      lr_elements = LR_ROOT->GET_ELEMENTS_BY_TAG_NAME(
    *      DEPTH     = 0
          NAME      = 'bookmarkStart'
          NAMESPACE = 'w'
      lr_itr_bookmarkStart = lr_elements->create_iterator( ).
      DO.
        lr_node = lr_itr_bookmarkStart->get_next( ).
        IF lr_node IS INITIAL. EXIT. ENDIF.
        lr_attributes = lr_node->get_attributes( ).
    * Read attribute "w:name" of element "w:bookmarkStart"
        lr_attribute = lr_attributes->get_named_item(
          NAME      = 'name'
          NAMESPACE = 'w'
        lv_name = lr_attribute->get_value( ).
        if iv_name <> lv_name. continue. endif.
    * Element "w:fldSimple" was found, iv_name = Name of bookmark to fill
        lv_bookmark_found = abap_true.
        lr_node_bookmarkStart = lr_node.
    * Read attribute "w:id" of element "w:bookmarkStart"
        lr_attribute = lr_attributes->get_named_item(
          NAME      = 'id'
          NAMESPACE = 'w'
        lv_id_start = lr_attribute->get_value( ).
    clear lv_id_end.
    * .... work with parser
    * find element w:bookmarkEnd for relevant w:bookmarkStart, bookmarkEnd with the same id as bookmarkStart
            lr_node_next = lr_node->get_next( ).
            do.
              IF lr_node_next IS INITIAL. EXIT. ENDIF.
              lr_node = lr_node_next.
              lv_name = lr_node->get_name( ).
              if lv_name = 'bookmarkEnd'.
                lr_attributes = lr_node->get_attributes( ).
    * Read attribute "w:id" of element "w:bookmarkEnd"
                lr_attribute = lr_attributes->get_named_item(
                  NAME      = 'id'
                  NAMESPACE = 'w'
                lv_id_end = lr_attribute->get_value( ).
              endif.
              if lv_id_start = lv_id_end.
                lr_node_parent = lr_node->get_parent( ).
                lr_node_bookmarkEnd = lr_node.
                er_node_bookmarkEnd = lr_node.
                exit.
              else.
                lr_node_next = lr_node->get_next( ).
    * remove elements between bookmarkStart and bookmarkEnd
                lr_node->remove_node( ).
              endif.
            enddo.
    * insert new elements between boomarkStart and bookmarkEnd
    CALL METHOD me->XML_RUN_TEXT_ADD
              EXPORTING
                IR_PARENT = lr_node_parent
                IR_REF    = lr_node_bookmarkEnd
                IV_VALUE  = iv_value
              IMPORTING
                EV_OK     = lv_bookmark_ok.
      EXIT.
    ENDDO.
    For example, XML with bookmark:
    <w:bookmarkStart w:id="0" w:name="testing123"/>
    <w:r>
    <w:t>This is sentence two.</w:t>
    </w:r>
    </w:p>
    <w:p>
    <w:r>
    <w:t xml:space="preserve">This </w:t>
    </w:r>
    <w:bookmarkEnd w:id="0"/>
    4. replace file 'word/document.xml' in zip (.docx) with class CL_ABAP_ZIP.
    CL_ABAP_ZIP->DELETE
    CL_ABAP_ZIP->ADD
    5. You can store result where you need.
    6. You can use for editing by users classic dynpro with container with word.

  • I cannot send a Pages document, Word format via email from my ipad if it has a picture in the the doc.  I can send a Word doc if it does not have a pic in it or pdf with a pic.  Any thoughs why a word doc with a pic in it won't email in Pages?  thanks

    I cannot send a Pages document, Word via email if the doc contains a picture.  If I email a Pages doc without a pic in Word format or pdf with a pic it with go through to sender?  Not sure why Pages won't send Word doc with a picture in it.  I check the security on the email recipient and the email doesn't get blocked or throw in the junk box?
    thanks,
    drainguy41

    If you have upgraded to Mountain Lion, Save As… has returned to the File menu when you hold down the Option/alt key. But you don't really "save" as other file types, you translate & export as Word or RTF or text or PDF & that is easily done by going to File > Export or Share > Export.
    Also, please do us all a favor & don't use all capitals in your posts, either the body of the post or the title. All caps is the internet equivalent of shouting & is very hard to read.

  • Creating PDF via Word Macro using Adobe Acrobat 9 Pro

    I've been trying to create a macro for Word documents that will write the document out as a PDF and named as C:\temp\temp.pd. My macro to date is below, but everything I've tried so far results in a .prn file, though it is named temp.pdf. Trying to record the Macro using toolbar buttons or dropdowns yields a macro with no code. Any suggestions?
    Sub WritePdfFile()
    ' WritePdfFile Macro
        Windows(1).Activate
        ActivePrinter = "Acrobat PDFWriter"
        Application.PrintOut FileName:="", OutputFileName:="C:\temp\temp.pdf", Range:=wdPrintAllDocument, Item:= _
            wdPrintDocumentContent, Copies:=1, Pages:="", PageType:=wdPrintAllPages, _
            Collate:=True, Background:=True, PrintToFile:=False

    I have tried using ActivePrinter = "Adobe PDF" . However, the results are the same. The file created is a prn file.  I've seen some references to a MS Word 'PDF Maker' plug-in that perhaps should be used, but this does not seem necessary to me. This is because, with the same document opened in Word, I can select the 'Convert to Adobe PDF' toolbar button and this creates a temp.pdf file as I need it. The challenge seems to be to get the same behavior through the use of a Macro.

  • OLE with c# for SAP AL - Error calling application via OLE GUIScanDoc

    Hi,
    I am creating a small scanning application which should be accessible from SAP. I read the documents  from SAP side which says, we need to create an OLE 2.0 Enabled application. I created an OCX application in vb6 and configured with SAP. the call is going to my ocx application but dont know how to implement "GUIScanDoc @AID,N" in my application. I tried to create a function named GUIScanDoc () in ocx but getting the same error stating *"Error calling application via OLE GUIScanDoc".
    If anyone has solution then plz plz help me out.
    Thanks in advance.
    P. Ramesh
    Edited by: rapr04 on May 22, 2011 2:37 PM

    I think you posted this in the wrong section of the forums, this area is just for SDK's relating to the BusinessObjects products.

  • Working with Word Templates and signed Word macros storing documents in SAP

    HI,
    we are storing word documents in the SAP BDS. The documents contain macros. The security settings for word macros cannot be reduced in our environment.
    So the documents / macros were signed. They work well. but as soon as they have been stored in the SAP BDS, we get the error message "You have modified a signed project.You do not have the correct key to sign this project. The signature will be discarded"
    After that the word macros do not run.
    Does anybody know this problem and the solution?
    Regards
    Harald

    And this is related to workflow in what way?
    Regards,
    Martin

  • How can I use Automator to open and save Word docs with links?

    Hi-
    I'm having trouble building a Workflow to open and save Word docs with links.
    My Workflow so far:
    1. Get Finder items
    2. Copy Finder items (to new folder)
    3. Rename selected items
    4. Open selected items (Word docs)
    Three problems occur.
    The first is a Word 2004 problem -- I can't get the warning "This document has links in it; do you want to open it with/without updating the links" to go away (Unilke the Macro warning toggle capability, there is nothing in the Preferences for Word 2004 that addresses the links warning, as far as I can tell; any insight you can shed on this would be terrific.)
    The second problem happens with Automator: if I manually accept the update of the first document's links, Automator opens that document but then halts completely, even though I've instructed it to open multiple documents.
    The third problem I have is that there's no Finder action in Automator that allows me to save the document that's now open (as far as I can see).
    Any suggestions for how to fix? If I can get this to work, and scheduled in iCal, it will be an unbelievable time saver.
    Thanks,
    Jeremy
    PowerPC G5   Mac OS X (10.4.6)  

    Hi there Jeremy,
    to do this you are going to have to add in some Run AppleScript steps...
    These will rely on GUI Scripting. So first you need to activate GUI Scripting.
    Now we need to add in a Run AppleScript action to the end of your workflow...
    This will replace your current number 4 in the workflow (Open Selected...)
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">on run {input, parameters}
    set allItems to every item of input
    repeat with currItem in allItems
    tell application "TextWrangler"
    open currItem
    end tell
    activate application "TextWrangler"
    tell application "System Events"
    tell process "TextWrangler"
    delay 2
    --when the Word document is opened I have told it to press okay !
    --I don't know what key you want it to press in the dialog box
    keystroke return
    delay 2
    --save the doc
    keystroke "s" using command down
    delay 5
    --close the doc
    keystroke "w" using command down
    end tell
    end tell
    end repeat
    return input
    end run</pre>
    The above script should open each Word Document, press a button in the dialog box then do a save and then close the doc...then loop through the rest of them.
    You need to replace the name Text Wrangler with Microsoft Word (or whatever it is called!), I don't have it on my Mac.
    You will have to let me know what button needs pressing in the first dialog, if it isn't the 'highlighted ' one then we will have to amend the script...
    regards
    Ric

  • Why can't I print a document created on my MacBook Air with Pages via a wired Lexmark X2650 printer?

    I am unable to printe a document I created on my Mac with Pages via a wired Lexmark X2650 printer. Of course, I have already confirmed that it is correctly set up and connected. Why?
    Thank you.
    <Email Edited by Host>

    TextEdit is an application on your Mac.
    Type TextEdit into Spotlight (magnifying icon top right on the menubar) to quickly locate and open it.
    It is the basic Text/Word Processor (but actually very capable) that comes with all Macs and a good place to test differences if you hit a problem.
    Peter

  • OLE2 Doc/Code snippet to assist in creating a word doc with underlined text

    I would like to use OLE2 to create a simple Word document. I would like some of the text to be bold/underlined and the rest of the text to be regular. There seems to be a serious dearth of information regarding OLE2 in conjunction with PS/SQL in Word applications. We're running Forms 6 and Oracle 9i.
    I don't believe that I need to use the techniques described in the Forms Manual (OLE2 containers, etc.). I have managed to create a Word doc and write some text to it but I've been unable to find out/guess at the syntax that I'd need to control bolding and underlining. It would be a big help if I could just find the syntax for Word OLE2 commands. During my documentation search, I seem to remember a post that mentioned 'Reference 2' and maybe 'Reference 3' as a source of information related to OLE2 in PL/SQL code. If anyone can give me a shove in the right direction I'm more than willing to read the manuals. I won't be too disappointed if someone could send me a code snippet either!
    Thanks,
    Ron Walker

    Hi Ron,
    Office ships with a number of resources that you will find indispensable for the sort of work you're doing. Take a look at the VBA IDE (Visual Basic for Applications IDE). You may already be familiar with it, if you've ever written a Word macro, but to call it a macro editor sells it short -- it is a full-blown development environment. Its Object Browser allows you to browse Word's object model, search by keyword, and view call syntax.
    In case you aren't familiar with the VBA IDE, try this:
    1. Open Word
    2. Switch between Word and the VBA IDE by pressing <Alt><F11>
    3. Open the Object Browser by pressing <F2>
    Spend some time familiarizing yourself with the Object Browser. Constrain its scope by selecting the Word library instead of <All Libraries> (the default). Learn to search by keyword. Click on items within your results for details. If Visual Basic Help is installed, pressing <F1> will raise help on a selected item.
    Visual Basic Help may not be part of the Compact or Typical install. Running Office Setup, either from the install CD, or through Add/Remove Programs under Control Panel, will allow you to add the feature. (The Office installer lists Visual Basic Help in the Office Tools section.)
    I have found the VBA IDE to be the perfect place for prototyping and testing automated processes. It is a far friendlier environment for learning Office automation, as it offers code completion and context-driven help. Once the process works, I manually translate my VBA routine into Forms PL/SQL, which is fairly painless. I've written a short tutorial, that I will post shortly -- I didn't want to bury it in this thread!
    Hope this helps,
    Eric Adamson
    Lansing, Michigan

  • Can't open Word docs with Pages 08

    Since upgrading to SL I found that I can no longer open Word documents sent to me via email attachments. Can this be remedied? I thought Macs were able to "translate" Word files.
    Help!

    I did discover I can open Word docs with Text Edit, but it's a multi-step process now. I really don't want to upgrade to iWork 09 and I'm not sure that would solve the problem. I also have to use Quick Time now to open movies in iPhoto. Another multi-step process. I'm not very happy with SL.

  • Word macro from Forms

    How can I start a macro in Word from Forms with the DDE-package? For Excel I use this command ('update' is the macro-name):
    DDE.Execute(ConvID, [run "'test.xls!update"]', 10000);
    Does anybody know the right approach for a Word macro?
    Thanks.
    null

    You should use OLE2 instead of DDE.
    Use this procedure if you're using Word version >= 97:
    PROCEDURE RUN_MACRO(cMacroName VARCHAR2) IS
    objWordApp OLE2.OBJ_TYPE := OLE2.CREATE_OBJ('WORD.APPLICATION');
    objArgList OLE2.LIST_TYPE := OLE2.CREATE_ARGLIST;
    BEGIN
    OLE2.ADD_ARG(objArgList,cMacroName);
    OLE2.INVOKE(objWordApp,'Run',objArgList);
    OLE2.DESTROY_ARGLIST(objArgList);
    OLE2.INVOKE(objWordApp,'QUIT');
    OLE2.RELEASE_OBJ(objWordApp);
    END;
    you can contact me for further explanation.
    Carlos

  • Opening word document with linked PPT inside

    Hi everybody,
    this is an error occuring using KM functionality, which could also be cause by the local Microsoft environment, but perhaps anybody knows this ...
    We are using EP 6.0.2.4.8 with CM 6.0.2.4.6
    In several KM navigation iviews we have linked folders from a file system repository with word documents inside. Users have problems opening the word documents which have powerpoint files linked inside the document. The powerpoint files are not embedded, but linked and shown as object (not as symbol or hyperlink).
    This means: word document is openened via http://<portal>/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/<folder>/<file>.doc
    The PPT linked inside leads to
    <fileserver>\<share>\<file>.ppt
    In some user environments (depending on local security policies(?) and local user/word options) word tries to automatically refresh the linked objects and then word crashes with an exception.
    So far, a Microsoft problem, but:
    when I copy the same word document to a simple IIS webserver an open it, the file is opened properly ...
    Is this problem known somewhere? As it is a local application error, I do not get any error in the portal logs ...
    Best regards,
    Martin

    Hello,
    Thanks for your answer. Since I work at a customer's office, I couldn't reply before because it took me some times to perform the tests.
    I tried to embed the images in Word before importing the document into Robohelp 8. The problem remains. RH creates the images into a new folder (and names the images "image001", "image002", and so on). Therefore, the link with the original images is lost.
    So, if we modify the image linked to the Word document, we are obliged to apply the same changes in the images created by RH.
    The idea would be to have only one image folders used both by RH and Word so that if we change our images, the changes apply in all our files.
    This option was available in RH x5.
    Best Regards,
    Isabelle

  • Cannot search file content on Word document with embedded Excel table

    Cannot search file content on Word document with embedded Excel table. I have Windows 8.1 64-bit and Office 2010 Professional. Only phrases from within Excel tables are not searchable. I have many Word documents with embedded Excel table.
    I use it for my invoices. Those invoices are converted to pdf to be sent via mail. Searching the same phrases in related pdf files Works fine. And yes, folders are indexed, searching service is active......... For example I can find all invoices that have
    specific address or name, which is located in word document, but cannot find invoices with specific item name or price, being that information is in embedded Excel table. (not linked, embedded). I thought that is a question for Windows forum, but guys directed
    me here on Office forum. To clarify, I do not use Ctrl+F inside some document, but Windows Search in my folders. Probably the same happens in Office 2013.
    Thank you.

    Hi, I have a lot of Word documents (invoices, offers). Main part of those documents is embedded Excel file because it is easier to do mathematics in Excel than in Word. There are columns with description, unit price, quantity, taxes... Now, I need
    to find who bought HP switch 2530-24G last year. I open folder with last year invoices and search "2530". Cannot find any. But if that document was converted to pdf for mail, than I can find that phrase. Windows search does not work for content if the content
    is in embedded file.

Maybe you are looking for

  • Acrobat 7 Pro will not install from Adobe download 22020134.exe

    I run Windows XP.  I uninstalled my copy of Adobe 7 Pro to transfer it to another computer.  I successfully installed the download provided by Adobe (which replaces original disks) on the other computer.  I found I was having general problems with th

  • How to bind DATE variables in SQL*Plus

    I have a stored procedure in a package that has a DATE OUT parameter myPackage.myProcedure( outDate OUT DATE ) I am trying to test this from SQL*Plus How do I specify a Bind variable for the outDate? The VARIABLE command does not allow DATE types? If

  • How to Validate Newly Added Fields for ME22n and ME23n

    Hi Experts, I have added 2 fields at the item level of PO Change and display(ME22n and ME23n). I used the BADIs ME_GUI_PO_CUST and ME_PROCESS_PO_CUST and got that displayed. I got a new tab at Item level and my fields are displayed there. My problem

  • How to list mappings used in flow

    Hi all Is there a table or view which will list all objects (mappings) used in a given processflow? Any tip appreciated KR Rolf

  • Service BBPPU99 could not be started in ITS

    In EBP ITS system, we try to shop via service BBPPU99 (shop). Web site shows: Flow Execution Failed The module provide returned following error message: No Template Also, diagnose log files report as: XGatHandleResponse: No template defined. Please a