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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto-Save after editing an XL document 1

Status
Not open for further replies.

JavaTurkey

Technical User
Dec 24, 2001
42
US
I've got some VBA code which edits a specific XL document...

Set xlobj = CreateObject("excel.application")
With xlobj
.Workbooks.open Filename:="R:\All-In-One\po_local.xls"
.Range("B8").select
.ActiveCell.FormulaR1C1 = Me!Name
.Quit
End With

it works great, except when it runs, it pops up asking me if I'd like to save changes...any way to just hardcode "YES" ?

 
Try sendkeys:

Set xlobj = CreateObject("excel.application")
With xlobj
.Workbooks.open Filename:="R:\All-In-One\po_local.xls"
.Range("B8").select
.ActiveCell.FormulaR1C1 = Me!Name
.Quit
SendKeys "y"
End With
 
i don't like send keys...

personaly, I would try to use some thing like
.save
so, some thing like this... (keeping in mind, this is off the top of my head, so i'm not to sure on it)

Set xlobj = CreateObject("excel.application")
With xlobj
.Workbooks.open Filename:="R:\All-In-One\po_local.xls"
.Range("B8").select
.ActiveCell.FormulaR1C1 = Me!Name
.Save
.Quit
End With junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Hi junior1544,

Much neater! I'm giving you the star because that's really helped me. Thanks.
 
I'm guessing it worked?? I worked with linking excel and access a bit like this, and I thought that's how I did what you're looking do it...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top