I am VERY new to scripting and I am already frustrated I can't figure this out.
Here's what I have so far:
Set objExcel = CreateObject("Excel.Application") objExcel.Visible = False objExcel.DisplayAlerts = FALSE Set objWorkbook = objExcel.Workbooks.Open("C:\Documents and Settings\Pat\Desktop\ACT! Excel ole db.xls") Set objWorksheet = objWorkbook.Worksheets(1)
objWorkbook.Save() objExcel.Quit
I know line 4 doesn't belong there because the file ALREADY is running and I don't need another one to be opened. I just need to work with the existing one.
I am trying to SAVE and CLOSE an ALREADY running excel file THAT ALREADY HAS A FILE NAME that is hidden from view.
WHAT do I need to do to change this to make it work?
Thanks!
Pat
< Message edited by patgenn123 -- 6/15/2008 6:12:02 PM >
try to use GetObject instead of CreateObject: Sorry, my fault: Ignore the following block of bad code (I edited the wrong file and tested the unchanged version).
This works; given a suitable recalc.xls:
Good luck!
ehvbs
< Message edited by ehvbs -- 6/15/2008 8:42:32 PM >
Thanks! I looked at your script and it's way way way over my head. I don't get it and right now I am getting pretty mad(not at you), but at myself.
All I did is replace CreateObject with GetObject in the first line and I get this error:
--------------------------- Windows Script Host --------------------------- Script: C:\Documents and Settings\Pat\Desktop\rthdfgh.vbs Line: 1 Char: 1 Error: Invalid syntax Code: 800401E4 Source: (null) --------------------------- OK ---------------------------
Can you help me work with what I have? I am really at my whits end and don't know what to do. I know this K.I.S.S. method is used around here. Can you keep it real simple if you would like to help me?
Thank you again. Yet, I still don't understand the script.
I tried to be too general not thinking that there was any difference(because I didn't know)
Here is what I am trying to do:
I have a database(ACT!) which I am pretty sure is irrelevant. When I open ACT!, I open a "hidden" Excel ole db which is a refresh query on internal data from the database. I am sorry that I didn't say this before because I didn't think it would be an issue, but now it looks like it might be.
Ultimately, here is what I am looking to do: When ACT! closes, close and save the open/hidden Excel file. ((all of this is to be done with Excel being completely hidden))
I am 100% sure the database is irrelevant to this request. One could open the excel file and Excel"refreshes itself" without ACT! being open(even though nothing is being fed from the database when ACT! is closed).
I didn't want to complicate things by mentioning the database.
The reality is that ACT! will be closed when I save/close Excel.
All I am looking to do is save/close that Excel file all while it's hidden. The excel file NEEDS to be hidden, saved and closed right after ACT! is closed.
I still don't get it. Obviously the .xls interacts with the database. Does it execute a query? Are you interested in a copy of these data? Can't you look at the connection parameters and the query in the .xls and ask the database directly?
Does " The reality is that ACT! will be closed when I save/close Excel." mean: "I want to work with the .xls when/right after I closed ACT!"? Then the opened .xls will be empty, because "nothing is being fed from the database when ACT! is closed)"?
Why the hiding?
I think you should execute the steps you want to do 'by hand' - without any VBScript. After you get a stable process, you can think about doing it automatically with a script.
I feel that the database (and how it interacts with the .xls) is very pertinent to a solution and I kind of loose all hope that I can help you.