Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute VBA on Excel File From Access VBA

Status
Not open for further replies.

LaCour

MIS
Jul 15, 2004
53
0
0
US
I am creating an Excel report via VBA in Access. Then, to remove the new line characters in the Excel file, I run:

Cells.Replace What:=vbCr, Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

from Excel.

Is it possible to run this line of code against the *.xls file from the Access VBA?

Let me know if you have thoughts on this.

Thanks
Blair
 
Not sure if this will work but...
Did you look at DDE?
=DDESend("Excel", "Sheet1", "R1C1", "Some text")

there are a bunch of DDE commands

DougP, MCP, A+
 
Blair,

By setting a reference to the Excel object library in Access, you have the ability to use any of the Excel objects within Access. For example:

Code:
Dim xlAPP as Excel.Application
Dim xlWBK as Excel.Workbook
Dim xlSHT as Excel.Sheet

Set xlAPP = New Excel.Application
Set xlWBK = xlAPP.Workbooks.Open( ... workbook path/name ... )
Set xlSHT = xlWBK.Worksheets( ... worksheet name ... )

     xlSHT.Cells.Replace What:=vbCr, Replacement:="", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False

Set xlSHT = Nothing
Set xlWBK = Nothing
Set xlAPP = Nothing

I believe that should work.

Randy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top