Creating a workbook from Access

twoplustwo

Registered User.
Local time
Today, 13:21
Joined
Oct 31, 2007
Messages
507
Hi all, hope you're all well.

Hopefully a quicky, not sure what I'm missing.

I am creating a workbook a outputting an array after some of its values have been run through some parameters.

My code for creating the and naming the workbook:

Code:
Set wbOutput = xlApp.Workbooks.Add
With wbOutput
   .Name = .Path & "\NHH GMTV Forecast " & Now()
End With

I get the compile error "Can't assign to a read only property".

Any ideas?
 
I assume you want to create a new workbook?

if that is the case have a look here and at the example

http://msdn.microsoft.com/en-us/library/aa221273(office.11).aspx

As msdn link never stay around long here is the example

Code:
Set NewBook = Workbooks.Add
    With NewBook
        .Title = "All Sales"
        .Subject = "Sales"
        .SaveAs Filename:="Allsales.xls"
    End With
If you are trying to but "Now()" into the name of a file I am not sure that will work in Windows.
 
Thanks darbid, excellent.

I formatted the Now() part as DD_MM_YYYY_HHMMSS in the end as it didn't like it first time round :)

Thanks again.
 

Users who are viewing this thread

Back
Top Bottom