ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   call new workbook (https://www.excelbanter.com/excel-programming/428761-call-new-workbook.html)

Kirsty

call new workbook
 
I am trying to have my macro open a workbook during the run.
I recorded the macro, and opened the workbook, however, when I now run the
workbook, this is not working. Can anyone help me with how to open a new
workbook during a macro

Jacob Skaria

call new workbook
 
'To open new workbook
Workbooks.Add

'To open existing workbook
workbooks.Open "<filename"
--
If this post helps click Yes
---------------
Jacob Skaria


"Kirsty" wrote:

I am trying to have my macro open a workbook during the run.
I recorded the macro, and opened the workbook, however, when I now run the
workbook, this is not working. Can anyone help me with how to open a new
workbook during a macro


Patrick Molloy

call new workbook
 
DIM wb as WorkBook
SET wb = Workbooks.Add()

you can now control the workbook using the variable

eg save is
wb.SaveAs {params}
wb.Close {params}

DIM ws as Worksheet
set ws = wb.ActiveSheet

and so on



"Kirsty" wrote in message
...
I am trying to have my macro open a workbook during the run.
I recorded the macro, and opened the workbook, however, when I now run the
workbook, this is not working. Can anyone help me with how to open a new
workbook during a macro




All times are GMT +1. The time now is 01:04 PM.

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