LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Automation of Excel Report using Access Data

I have data in a query that I have exported from Access using Transfer text
to a csv file. I set up an excel spreadsheet for the report and recorded a
macro in excel that imports the data from the csv file and links the data to
the report.

The problem is running the Excel macro as part of the code for the button
click in my Acces form. I am getting a runtime error, saying that the macro
cannot be found. Everything is spelled correctly.

Can anyone provide any insight?

Thanks

Here is the code for the button click in Access:


Dim xlsApp As Excel.Application
Dim xlswkb As Excel.Workbook
Set xlsApp = CreateObject("Excel.Application")

xlsApp.Application.Visible = True

Set xlswkb = GetObject("W:\Weekly Reports\Report Templates\Report_Macros.xls")

With xlsApp.Application
.Workbooks.Open "W:\Weekly Reports\Report Templates\Report_Macros.xls"
'this is the point were the code gives the run time error, stating that the
file cannot be found
.Run "W:\Weekly Reports\Report
Templates\Report_Macros.xls!UpdateFieldSalary_Data "
.ActiveWorkbook.Sheets("template").Range("B5").Val ue = ReportTitle
.ActiveWorkbook.SaveAs Filename:= _
"W:\Weekly Reports\Final Reports\" & Format(Me.txtWeekEnding,
"yyyymmdd") & "FieldSal.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End With
xlsApp.Application.ActiveWorkbook.Close

xlsApp.Application.Run "Macros Worksheet.xls!UpdateMaintOT_Data"

With xlsApp.Application
.ActiveWorkbook.Sheets("Report").Range("A2").Value = ReportTitle
.ActiveWorkbook.SaveAs Filename:= _
"W:\Weekly Reports\Final Reports\" & Format(Me.txtWeekEnding,
"yyyymmdd") & "MaintOverPer.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End With

xlsApp.Application.ActiveWorkbook.Close
xlsApp.Application.Workbooks.Close
xlswkb.Close
xlsApp.Application.Quit

Set xlsApp = Nothing
Set xlswkb = Nothing

DoCmd.SetWarnings True

End Sub


 
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
automation excel to access goaljohnbill Excel Programming 1 May 21st 09 05:25 AM
Automation to Excel from Access Bob Barnes Excel Discussion (Misc queries) 1 February 11th 08 05:18 AM
automation from access into excel SAm Excel Discussion (Misc queries) 7 January 27th 06 02:49 AM
VLookup to merge Access Query data into Excel Report Vira-SJH Excel Discussion (Misc queries) 0 January 10th 06 07:18 PM
Access automation from Excel AccessChallenged Excel Programming 2 December 31st 03 06:29 PM


All times are GMT +1. The time now is 06:08 PM.

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

About Us

"It's about Microsoft Excel"