flyingmeatball
flyingmeatball

Reputation: 7997

xlwings hide worksheets from python and book not visible

I'm using xlwings to control a workbook because I need to keep existing charts in tact (otherwise I'd use openpyxl). Is there a way to make the sheets hidden and to open a book within an app that is not visible?

to hide a sheet I've tried:

 wb.sheets[ws].Visible = False
 wb.sheets[ws].hidden= True
 wb.sheets[ws].Visible= xlveryhidden #vba syntax - bombs

The top two run, but don't do anything, the third bombs out.

I can create a new excel app and I can create a new book (which creates is new app). However, I want to open a specific book, but Book doesn't take a visible parameter - how do I open an existing workbook and not have it be visible?

excel  = xw.App(visible = False) #creates a new app that is visible
wb= xw.Book(filepath) #opens the already existing workbook, but it is visible - how do I make it part of the app above?

Upvotes: 0

Views: 4818

Answers (1)

flyingmeatball
flyingmeatball

Reputation: 7997

The solution was to call .api before calling a VBA function:

wb.sheets[ws].api.Visible = False

Upvotes: 5

Related Questions