ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Export from Access using vba (https://www.excelbanter.com/excel-programming/395182-export-access-using-vba.html)

JoeA2006

Export from Access using vba
 
I am exporting data from Access to excel using a vba routine in access. I
also need to create a macro in in the Excel sheet. The VBA creates a copy of
a template I have created. The data is loaded in the new copy of the
template. I recorded a macro to subtotal columns in the template.

The problem is after I load the data the Macro is no longer in the spread
sheet. How can I load the data then run a macro in the sheet to subtotal the
columns?

Michael

Export from Access using vba
 
You should make your Macro an addin:

Here is an example of addin

public class ThisAddIn

Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
' Start of VSTO generated code

Me.Application =
CType(Microsoft.Office.Tools.Excel.ExcelLocale1033 Proxy.Wrap(GetType(Excel.Application), Me.Application), Excel.Application)

' End of VSTO generated code

MessageBox.Show("Hello World")


End Sub

Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Shutdown

End Sub

End class


Please rate this posting if it was helpful it helps us provide better advise.


"JoeA2006" wrote:

I am exporting data from Access to excel using a vba routine in access. I
also need to create a macro in in the Excel sheet. The VBA creates a copy of
a template I have created. The data is loaded in the new copy of the
template. I recorded a macro to subtotal columns in the template.

The problem is after I load the data the Macro is no longer in the spread
sheet. How can I load the data then run a macro in the sheet to subtotal the
columns?



All times are GMT +1. The time now is 01:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com