Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to Excel: Open, Read, Write, Save, Quit



  • Please log in to reply
8 replies to this topic
sabukz
  • Members
  • 33 posts
  • Last active: May 09 2013 06:13 AM
  • Joined: 15 Dec 2009

Guys,

 

Need help with open, read, write, save and quit a excel app

 

Please correct if am wrong.

 

Script:

 

 

Xl := ComObjCreate("Excel.Application") ;create handle
Xl.Workbooks.Open(c:\test.xls) ;select xls file
 

Gui, Add, Edit,  vVariable_name ;get input

 

Gui, Submit ;save the input

 

 

Loop
{
     if(Xl.Range("A" . A_Index).Value = "")
     {
           Xl.Range("A" . A_Index).Value := Variable_name
           break
     }
}
 
Xl_Workbooks.Save() ;save workbook
Xl.Quit

 

 

 


Cheers!

sabukz
  • Members
  • 33 posts
  • Last active: May 09 2013 06:13 AM
  • Joined: 15 Dec 2009

Issue: After quiting, it pop's a window "Do you want to save changes you made to test.xls? save/dont save/cancel

 

How to get rid of this window???


Cheers!

rbrtryn
  • Members
  • 1177 posts
  • Last active: Sep 11 2013 08:04 PM
  • Joined: 22 Jun 2011

Reference here.

 

Need help with open, read, write, save and quit a excel app

 

 

There are  some examples here.

 

Issue: After quiting, it pop's a window "Do you want to save changes you made to test.xls? save/dont save/cancel

 

How to get rid of this window???

 

You could click one of the buttons happy.png


My Scripts are written for the latest released version of AutoHotkey.

Need a secure, accessible place to backup your stuff? Use Dropbox!


sabukz
  • Members
  • 33 posts
  • Last active: May 09 2013 06:13 AM
  • Joined: 15 Dec 2009

May be i was not in detail...

 

If i click SAVE, it saves, if i click on DONT SAVE, then its not gonna save, when why am i doing this script???

If i click on cancel, the excel process is running in the background.

 

I dont want that window to appear. Its not about the window but about the "Save" option

 

Like to have the excel saved after writing to the rows or columns.


Cheers!

CloudSurfer777
  • Members
  • 42 posts
  • Last active: Sep 04 2013 01:55 AM
  • Joined: 02 Oct 2012

Perhaps this answers your question?

 

XL.Workbooks.SaveAs(c:\test.xls)



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012

Xl_Workbooks.Save() ;save workbook

Don't think That Line works because "Xl_Workbooks" is not an ahk variable holding a pointer to an excel workbook object

But maybe something like this
Xl.ActiveWorkbook.save()
Hope it helps
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

sabukz
  • Members
  • 33 posts
  • Last active: May 09 2013 06:13 AM
  • Joined: 15 Dec 2009
✓  Best Answer

Changes made in the above script....

 

a:=Xl.Workbooks.Open(c:\test.xls)  ;select xls file

 

a.Save()    ;saving file

a.Close()   ;closing file

 

 

This script works!!!


Cheers!

milko
  • Members
  • 96 posts
  • Last active: Apr 29 2013 10:10 PM
  • Joined: 28 Jul 2010
you might find the solution posting on Microsoft Answers
 

:-)



Guest10
  • Members
  • 1216 posts
  • Last active: Oct 30 2015 05:12 PM
  • Joined: 27 Oct 2012

Issue: After quiting, it pop's a window "Do you want to save changes you made to test.xls? save/dont save/cancel

 

How to get rid of this window???

 

 

 

You could click one of the buttons happy.png

in Excel, i use the following macro to save without being prompted (clicking NONE of the buttons):

ThisWorkbook.Close Saved = False ' Close and save changes

can this be translated into AHK?