Using Macro to Open Excel File

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
 
J

Jim/Chris

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
 
M

Manuel

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
 
J

junior.carstensen

I am new to VB in Access, what is the lines of code to
make this run.
 
J

Jim/Chris

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

jim
 
J

Jim/Chris

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top