Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: App(visible=False) is broken #652

Closed
misakichan opened this issue Apr 7, 2017 · 10 comments
Closed

Mac: App(visible=False) is broken #652

misakichan opened this issue Apr 7, 2017 · 10 comments

Comments

@misakichan
Copy link

Hi, when I use xlwings XLSX file operation, set up the app = xlwings.App (visible = False) but in MAC will automatically open the Excel.app, and would not automatically open the Excel in win10.
mac os 10.12.4
windows10
Pycharm
python3.6
xlwings(last version from pypi)

@fzumstein
Copy link
Member

Are you seeing this with Excel 2016 on Mac?

@misakichan
Copy link
Author

Yes,Excel 2016 on mac(build15.32 170309)~

@fzumstein
Copy link
Member

Yeah Mac Excel 2016 plays difficult. It did work for Mac Excel 2011 but I am not sure if it can be properly handled with Mac2016... so for now consider it a known bug...

@misakichan
Copy link
Author

Ok, thank you very much for your answer ~

@fzumstein
Copy link
Member

fzumstein commented Apr 27, 2017

Ok so currently it opens Excel as non-frontmost application. Maybe it would be better to minimize it instead of hide it the same way as when you click the orange button (between the quit and maximize buttons).

@samsfisher
Copy link

Hello, the app is visible even with Excel 2011 Mac. Any ideas whats going wrong?

import xlwings as xw
# app = xw.App(visible=False,spec='/Applications/Microsoft Office 2011/Microsoft Excel')
app = xw.App(visible=False)

# PATH NAME
input_file_path = 'fname'
wb = app.books.open(input_file_path)
sht = wb.sheets['Log']
sht.range('D2').value = 'TT'
sht.range('D2').value 

@fzumstein
Copy link
Member

Hiding windows on Mac works differently from Windows. It only moves them away as frontmost window. I was testing app.api.windows[1].window_state.set(kw.window_state_minimized) to see if the behaviour is more of what is expected by minimizing it instead of hiding the window, but that wasn't much more promising.

I think for now the best way to do it is to call app.visible after opening the book:

import xlwings as xw
app = xw.App()

# PATH NAME
input_file_path = 'fname'
wb = app.books.open(input_file_path)
app.visible = False
sht = wb.sheets['Log']
sht.range('D2').value = 'TT'
sht.range('D2').value 

@kevinjordan
Copy link

While you figure out if/how to suppress visible state of excel workbook.
Is it also possible to suppress the prompt to handle automatic links for an excel document that has links to another document?
e.g. equivalent of 'ignore'

screenshot

@fzumstein
Copy link
Member

@kevinjordan see this issue: #562
you'd need to adopt it to mac though

@fzumstein fzumstein changed the title Mac: visible=False invalid Mac: App(visible=False) is broken Aug 19, 2020
@fzumstein fzumstein reopened this Aug 19, 2020
@fzumstein
Copy link
Member

fzumstein commented Aug 19, 2020

Looks like it's possible after all as it works properly when opening like this from the command line, see man open:

open -gjn -a /Applications/Microsoft\ Excel.app

@fzumstein fzumstein modified the milestones: 0.20.4, 0.20.5 Aug 19, 2020
@fzumstein fzumstein modified the milestones: 0.20.5, 0.20.6 Aug 27, 2020
fzumstein added a commit that referenced this issue Aug 30, 2020
@fzumstein fzumstein added the bug label Aug 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants