How can I open the third sheet from another file

  • Thread starter Thread starter Enescu Gabriel
  • Start date Start date
E

Enescu Gabriel

Hi, my name is Toni
1. I want to use an excelxp macro for open an other excel file directly to
the sheet number "n"?
2. In the same mod I want to open from excel a document from word templates.
Thank you in advance.
 
Hi Toni,

First part

Set oWb = Workbooks.Open Filename:="C:\myTes\myFile.xls"
oWb.Worksheets(3).Activate

On the second part, do you really mean you want to open a Word template from
within an Excel instance, or do you want to open a word template within a
Word instance, using Excel and VBA?

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Hi
for the first one try something like the following:

sub foo()
dim fname as string
dim path as string
Dim WBook As Workbook
application.screenupdating = false
path = "C:\"
fname = "filename.xls"
On Error Resume Next
Set WBook = Workbooks(fname)
On Error GoTo 0
If WBook Is Nothing Then
Workbooks.Open Filename:= path & fname
Set WBook = Workbooks(filename)
End If
WBook.worksheets(3).activate
application.screenupdating = True
end Sub
 

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

Back
Top