My Assistant
![]() ![]() |
|
|
Mar 26 2012, 12:00 PM
Post
#1
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
The following code runs the macro in the attached spreadsheet. It works fine the first time around but, the macro doesn't run from ACCESS the second time. Works fine if I run it from EXCEL.
Any thougths? CODE Public Sub OpenSafetyCrossAnyMonth()
Dim objXL As Object Dim strPath As String Dim strMonth As String strPath = "C:\IncidentReporting\SafetyCross_AnyMonth.xlsm" strMonth = Forms!frmReports.cboAnyMonth.Column(1) & "_" & Forms!frmReports.txtYearAnyMonth On Error Resume Next Set objXL = GetObject(, "Excel.Application") If TypeName(objXL) = "Nothing" Then Set objXL = CreateObject("Excel.Application") End If With objXL .Visible = False '.UserControl = True .Workbooks.Open strPath .Run "AnyMonth" .Activeworkbook.Application.DisplayAlerts = False .Activeworkbook.SaveAs "C:\IncidentReporting\SafetyCross_AnyMonth_" & strMonth & ".xls", FileFormat:=56 .Quit End With objXL.Close Set objXL = Nothing End Sub
Attached File(s)
|
|
|
|
Mar 26 2012, 12:13 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 8,106 From: CT |
i am just comparing what you have to something that I use and the only visual difference, which might not mean a darn thing is this so far...
yours:.... .Workbooks.Open strPath Mine:...... .Workbooks.Open FileName:=strPath |
|
|
|
Mar 26 2012, 12:27 PM
Post
#3
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
It opens fine, just doesn't run the macro.
|
|
|
|
Mar 26 2012, 12:37 PM
Post
#4
|
|
|
UtterAccess VIP Posts: 8,106 From: CT |
perhaps select the proper sheet first?? this is what I have. cleansed of course
oApp.Sheets("yoursheet").Select oApp.Run "start" |
|
|
|
Mar 26 2012, 01:13 PM
Post
#5
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
Nope. That didn't help. I've attached the ACCESS db.
Attached File(s)
|
|
|
|
Mar 26 2012, 01:15 PM
Post
#6
|
|
|
UtterAccess VIP Posts: 8,106 From: CT |
did you do a compile ?
|
|
|
|
Mar 26 2012, 01:43 PM
Post
#7
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
Nope but, I will.
|
|
|
|
Mar 27 2012, 06:32 AM
Post
#8
|
|
|
UtterAccess Ruler Posts: 1,895 From: Massachusetts |
I did the recompile and that didn't change anything. Now, I am calling the macro at the Workbook_Open event and that is working.
Thanx for the help. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 11:28 PM |