Open Workbook Macro

G

Gene Augustin

I need the macro code line to open an existing workbook. The workbook name
is a string bookname


bookname is like AccountList.xls

Something Like: workbooks.open.workbook(bookname)
 
L

Laroche J

Gene Augustin wrote on 2009-03-13 15:25:
I need the macro code line to open an existing workbook. The workbook name
is a string bookname


bookname is like AccountList.xls

Something Like: workbooks.open.workbook(bookname)

The syntax is:
workbooks.open (filename:=bookname)
or
workbooks.open (bookname)

The first example is preferred when a method has a lot of arguments and you
don't need all of them. It's also clearer. The second example works because
filename is the first argument, others are omitted. In most circumstances
you can also make do without the parentheses around the arguments.

From the editor's help search for Workbooks, pick Workbooks Collection
Object in the left column, in the right pane click on Methods, then on Open.
You should read it. Here's the beginning:

Open Method

Syntax 1
expression.Open(FileName, UpdateLinks, ReadOnly, Format, Password,
WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable,
Notify, Converter, AddToMRU)

expression Required. An expression that returns a Workbooks object.

Syntax 2
expression.Open

expression Required. An expression that returns a RecentFile object.

FileName Required String. The file name of the workbook to be opened.
UpdateLinks Optional Variant. Specifies the way links in the file are
updated. If this argument is omitted, the user is prompted to specify how
links will be updated. Otherwise, this argument is one of the values listed
in the following table.
....


JL
Mac OS X 10.4.11, Office v.X 10.1.9
 
G

Gene Augustin

Thanks, it works. Plus special thanks for leading me to the help file. I
have searched there, but without knowing what to search for it hasn't been
helpful.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top