Loading ...
Sorry, an error occurred while loading the content.

Re: [BATCH WORLD] open excel with enable macros

Expand Messages
  • Abhijat Singh
    Hi Group, OK. This is my last email on this group for this topic. I just wanted to thank Parag for the link he provided. That did the trick. I have not been
    Message 1 of 8 , Dec 30, 2010
    • 0 Attachment
      Hi Group,
      OK. This is my last email on this group for this topic. I just wanted to thank Parag for the link he provided. That did the trick.
      I have not been professionally trained on dos, or VB script or VBA, but I just finished a code which involves all the three.

      Thanks to you guys!

      On that note ..

      WISH YOU ALL A VERY HAPPY & PROSPEROUS 2011 !

      See you next year!

      Kind Regards,
      Abhijat.

      --- In batchworld@yahoogroups.com, Parag Doke <paragpdoke@...> wrote:
      >
      > Hi Abhijat.
      > Right, this ceases to be a batch files related topic. Maybe this post could
      > help:
      > http://www.mvps.org/access/modules/mdl0007.htm
      >
      > Also, in case you want to invoke VBScript files from a batch file and wait
      > for the execution to finish (rather than creating an exe which will hide the
      > source code), this might help (batch file code below):
      > ---
      > cscript <path to vbs file> <arguments>
      > ---
      > The advantage with that is that WScript.Echo statements can be as debug
      > messages (whereas, to achieve the same from VB - messages echoed to stdout -
      > some additional steps might be needed). If any WScript.Echo messages are
      > expected to be message box alerts, then replace script with wscript in the
      > above batch file line.
      >
      > Thanks,
      > Parag Doke
      >
      > On Thu, Dec 30, 2010 at 6:46 AM, Abhijat Singh <mail_abhijat@...>wrote:
      >
      > >
      > >
      > > Hi Group,
      > > Not sure if this is any longer a post for "BatchWorld", but I had to reply.
      > > Should any member think that this is irrelevant here, please email and I
      > > shall discontinue.
      > >
      > > Parag,
      > > Taking the lead from you, I built this simple exe file using the following
      > > VB code
      > >
      > > Option Explicit
      > > Sub main()
      > > Dim xlFileName As Variant
      > > Dim xlapp, xlbook As Object
      > > Set xlapp = CreateObject("Excel.Application")
      > > xlFileName = "S:\users\abhijat\FactSet\Daily_Files\IB_FactSet_Daily_US.xls"
      > > Set xlbook = xlapp.WorkBooks.Open(xlFileName)
      > > Set xlbook = Nothing
      > > xlapp.quit
      > > Set xlapp = Nothing
      > > End Sub
      > >
      > > In IB_FactSet_Daily_US.xls I have called another macro (say, XYZ)under
      > > Workbook.Open. XYZ further processes the rest of the request and retreives
      > > daily files from factset server.
      > >
      > > The .exe is called from a (parent) DOS batch script. Once the VB script and
      > > the excel download is over, the pointer comes back to the DOS batch script
      > > and then several routine checks are performed.
      > > Though novice, this is working nicely for me for the moment.
      > >
      > > Now, I am looking to better it.
      > > 1. I want to avoid calling the macro XYZ from Workbook.Open. For this, I
      > > guess I have to do something like xlApp.Run(MacroName). However, neither
      > > xlApp.Run("XYZ") nor xlApp.Run(Module1!XYZ) working for me.
      > >
      > > Any suggestions please.
      > >
      > >
      > > Kind Regards,
      > > Abhijat
      > >
      > > --- In batchworld@yahoogroups.com <batchworld%40yahoogroups.com>, Parag
      > > Doke <paragpdoke@> wrote:
      > > >
      > > > Abhijat,
      > > > VBScript might be better at achieving what you intend to do. Try creating
      > > an
      > > > instance of Excel.Application and then take it forth (see if
      > > > the AutomationSecurity property could help).
      > > > Untested:
      > > > Option Explicit
      > > > Dim xlApp
      > > > Set xlApp=CreateObject("Excel.Application")
      > > > Const msoAutomationSecurityLow=1
      > > > Const msoAutomationSecurityByUI=2
      > > > Const msoAutomationSecurityForceDisable=3
      > > >
      > > > xlApp.AutomationSecurity=3
      > > > xlApp.Workbooks.Open "C:\Macros.xls"
      > > >
      > > > Thanks,
      > > > Parag Doke
      > > >
      > > > On Thu, Dec 23, 2010 at 9:14 PM, foxidrive <foxidrive@> wrote:
      > > >
      > > > >
      > > > >
      > > > > On 24/12/2010 02:31, Abhijat Singh wrote:
      > > > > > Hi Group, I am building a dos script for automation. One of the
      > > > > > things it has to do is to run open a excel workbook and run a macro.
      > > > > > I have put the call of the macro in workbook.open, so whenever thhe
      > > > > > workbook is open, the macro is run automatically. The problem is when
      > > > > > I invoke the .xls workbook, it asks me to enable/disable macros.
      > > > >
      > > > > How do you invoke the .xls workbook?
      > > > >
      > > > >
      > > > > > I was wondering if there is a way out in dos to to "Enable macros". I
      > > > > > can always lower the security of excel for this but I really don't
      > > > > > want to use that option.
      > > > >
      > > > > There's probably a command line switch for Excel.
      > > > >
      > > > >
      > > > > > Also, if there is a way to invoke a particular macro from a .xls
      > > > > > workbook, please share it with me.
      > > > >
      > > > > Also see the Excel documentation.
      > > > >
      > > > >
      > > > >
      > > >
      > > >
      > > >
      > > > --
      > > > Parag Doke
      > > > Save paper, save trees. Do not print emails/documents unless absolutely
      > > > necessary.
      > > >
      > > >
      > > > [Non-text portions of this message have been removed]
      > > >
      > >
      > >
      > >
      >
      >
      >
      > --
      > Parag Doke
      > Save paper, save trees. Do not print emails/documents unless absolutely
      > necessary.
      >
      >
      > [Non-text portions of this message have been removed]
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.