Using Macro to Open Excel File

  • Thread starter Thread starter Manuel
  • Start date Start date
M

Manuel

I'd like to have a Macro open an Excel file. The file is
located on a network drive (e.g. V:\Manuel\Work\Data.xls).

Anyone have any ideas how to accomplish this?

Thanks,

Manuel
 
Action: RunApp
Command Line: Application location "file location"

example
"c:\program files\microsoft office\office\excel.exe"
"V:\Manuel\Work\Data.xls"

watch for wordwrap

Jim
 
Thanks that helps a lot. However, it appears it doesn't
like spaces in the path and file name (which may have
nothing to do with Access). The MACRO opens Excel then
tries to find the file but at every space it says it
cannot find the file. Any suggestions on how get around
this?

Manuel
 
As long as the excel file name is enclosed in quotes spaces
do not make a difference. Check you syntax.

jim
 
Her is one way by converting the macro.

DoCmd.OutputTo acReport, "Report2",
"MicrosoftExcel(*.xls)", "c:\testoutputexcel.xls", False, ""

Here is another way from a previous post

Public Sub TestMacroRun()
Dim xlx As Object, xlw As Object, xls As Object, xlc As Object
Set xlx = CreateObject("Excel.Application")
xlx.Visible = True
Set xlw = xlx.workbooks.Open("C:\Filename.xls")
Set xls = xlw.Worksheets("WorksheetName")
Set xlc = xls.Range("A1")
' put code here to write into the cells etc.
' .
' .
' .
Set xlc = Nothing
Set xls = Nothing
xlw.Save
xlw.Close False
Set xlw = Nothing
xlx.Quit
Set xlx = Nothing
End Sub


Watch out for wordwrap

Jim
 
Back
Top