ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening workbook in invisible mode? (https://www.excelbanter.com/excel-programming/426676-opening-workbook-invisible-mode.html)

Gustaf

Opening workbook in invisible mode?
 
This code doesn't quite do what I want:

Set wbRemote = Workbooks.Open(temp, , True)

First, it opens the workbooks visibly, while I wish it to open in a hidden state. Second (probably due to the first), it changes the ActiveWorkbook. I also tried this

Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open temp, , True

This works, but I it lacks in clarity. I like having a Workbook object to refer to, rather than the Excel.Application object, which I'm less familiar with. Any hints on how to get a Workbook object referring to an open (but invisible) workbook?

Gustaf

Jeff

Opening workbook in invisible mode?
 
Try somthing like this...

Private Sub Workbook_Open()
Dim xl As Object
Dim wrkBook As Object

Set xl = CreateObject("Excel.Application")
Set wrkBook = xl.Workbooks.Add

xl.Visible = False
With wrkBook.Worksheets(1)
.Cells(1, 1).Value = "Hello"
.Cells(1, 2).Value = "world"
End With

End Sub


"Gustaf" wrote:

This code doesn't quite do what I want:

Set wbRemote = Workbooks.Open(temp, , True)

First, it opens the workbooks visibly, while I wish it to open in a hidden state. Second (probably due to the first), it changes the ActiveWorkbook. I also tried this

Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open temp, , True

This works, but I it lacks in clarity. I like having a Workbook object to refer to, rather than the Excel.Application object, which I'm less familiar with. Any hints on how to get a Workbook object referring to an open (but invisible) workbook?

Gustaf


RB Smissaert

Opening workbook in invisible mode?
 
Maybe a simple option is to open an .xla rather than an .xls.

RBS


"Gustaf" wrote in message
...
This code doesn't quite do what I want:

Set wbRemote = Workbooks.Open(temp, , True)

First, it opens the workbooks visibly, while I wish it to open in a hidden
state. Second (probably due to the first), it changes the ActiveWorkbook.
I also tried this

Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open temp, , True

This works, but I it lacks in clarity. I like having a Workbook object to
refer to, rather than the Excel.Application object, which I'm less
familiar with. Any hints on how to get a Workbook object referring to an
open (but invisible) workbook?

Gustaf



Barb Reinhardt

Opening workbook in invisible mode?
 
First, you can define a workbook object.
dim myWB as excel.workbook

and replace this
xlTmp.Workbooks.Open temp, , True

with this
Set myWB = xlTmp.Workbooks.Open ( temp, , True )

Then you can use the workbook object. The application object works much the
same as the workbook object.

If you don't want to see what's happening on the screen during execution,
put this

XlTMP.Screenupdating = false (after you define it)

and reset to TRUE when execution is done

HTH,
Barb Reinhardt

"Gustaf" wrote:

This code doesn't quite do what I want:

Set wbRemote = Workbooks.Open(temp, , True)

First, it opens the workbooks visibly, while I wish it to open in a hidden state. Second (probably due to the first), it changes the ActiveWorkbook. I also tried this

Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open temp, , True

This works, but I it lacks in clarity. I like having a Workbook object to refer to, rather than the Excel.Application object, which I'm less familiar with. Any hints on how to get a Workbook object referring to an open (but invisible) workbook?

Gustaf


Jim Cone[_2_]

Opening workbook in invisible mode?
 
Set oWb = xlTmp.Workbooks.Open(temp)
--
Jim Cone
Portland, Oregon USA


"Gustaf"
wrote in message

This code doesn't quite do what I want:

Set wbRemote = Workbooks.Open(temp, , True)

First, it opens the workbooks visibly, while I wish it to open in a hidden state. Second (probably due to the first), it changes the
ActiveWorkbook. I also tried this

Set xlTmp = New Excel.Application
xlTmp.Workbooks.Open temp, , True

This works, but I it lacks in clarity. I like having a Workbook object to refer to, rather than the Excel.Application object, which
I'm less familiar with. Any hints on how to get a Workbook object referring to an open (but invisible) workbook?

Gustaf


Gustaf

Opening workbook in invisible mode?
 
Gustaf wrote:

familiar with. Any hints on how to get a Workbook object referring to an
open (but invisible) workbook?


Many thanks for all the help on this.

Gustaf


All times are GMT +1. The time now is 03:36 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com