Jump to content

How to save a excel file when hide the workbook?


Recommended Posts

I open a excel file, but not set it Visible. I del some date, then want to save it. But i find it is not to save without visible.

How can it do it ?

This is my code

$FileName="C:\Test.xls"

$oExcelDoc = ObjGet($FileName)

$oExcelDoc.Worksheets(1).range("A1").Delete

$a1=$oExcelDoc.Worksheets(1).range("A1").value

Msgbox(0,"",$a1);>>>Show the value now

;>>>>>>>>>How to save this Excel file???<<<<<<<<
;>>>>>>>>>Don't activate it<<<<<<<<
Link to comment
Share on other sites

Who can help me?

<{POST_SNAPBACK}>

Here you go:
$FileName="C:\Test.xls"

; Open an Excel Workbook Object
$oExcelWB = ObjGet($FileName) 

; Oddly, even though we will not show the Excel interface in this example
; (with $oExcelWB.Application.Visible = 1), if you don't explicitly make the 
; window object visible before saving the workbook the window will be invisible 
; when you open interactivly
$oExcelWB.Windows(1).Visible = 1 

; Delete the contents of A1
$oExcelWB.Worksheets(1).range("A1").Delete

; Obtain the new A1 value and display in a MsgBox
$a1=$oExcelWB.Worksheets(1).range("A1").value
Msgbox(0,"",$a1);>>>Show the value now

; Save the workbook back to the file and close the workbook
$result = $oExcelWB.Save
$result = $oExcelWB.Close

Exit

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...