Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default run excel macro

Hi,

I am creating an excel spreadsheet automatically through
MS Access macro's "OutputTo" function. I also have the VBA
code of an excel macro to be run in this spreadsheet. For
testing purposes i open this excel file and manually copy
this code in excel macro and run it. But I actually want
to run this macro/VBA code on this spreadsheet
automatically through a batchfile or something without
having to open this excel file and copying this VBA code
in a macro inside.

Thanks,
Ketaki
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default run excel macro

Ketaki,

As you are familiar with VBA I recommend using VBA in Access to control the entire job. You can use code like the following to copy
Access data to a new Excel workbook:

Dim oXL As Object
Dim oXLWBook As Object
Dim oXLWorkSheet As Object
Dim rs As New ADODB.Recordset

Set oXL = CreateObject("Excel.Application")
oXL.Visible = True
Set oXLWBook = oXL.Workbooks.Add
Set oXLWorkSheet = oXLWBook.Worksheets(1)
rs.Open "Select * From tblSalaries", CurrentProject.Connection

oXLWorkSheet.Range("A1").CopyFromRecordset rs

You can continue to manipulate the Excel data from Access using similar code to the code you would use in Excel, except that you
will need to explicitly reference Excel as in the above code.

--

John Green - Excel MVP
Sydney
Australia


"Ketaki" wrote in message ...
Hi,

I am creating an excel spreadsheet automatically through
MS Access macro's "OutputTo" function. I also have the VBA
code of an excel macro to be run in this spreadsheet. For
testing purposes i open this excel file and manually copy
this code in excel macro and run it. But I actually want
to run this macro/VBA code on this spreadsheet
automatically through a batchfile or something without
having to open this excel file and copying this VBA code
in a macro inside.

Thanks,
Ketaki



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 1 February 5th 07 09:31 PM
My excel macro recorder no longer shows up when recording macro jack Excel Discussion (Misc queries) 3 February 5th 07 08:22 PM
passing arguments from an excel macro to a word macro KWE39 Excel Discussion (Misc queries) 1 July 7th 05 03:56 PM


All times are GMT +1. The time now is 12:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"