PC Review


Reply
Thread Tools Rate Thread

how can i open a second workbook using a vba code

 
 
swain.s@blueyonder.co uk
Guest
Posts: n/a
 
      25th Nov 2009

 
Reply With Quote
 
 
 
 
swain.s@blueyonder.co uk
Guest
Posts: n/a
 
      26th Nov 2009
hi i have tried the code that you recommended but i cannot get it to work

"Dave Peterson" wrote:

> dim wkbk2 as workbook
> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
>
>
> (E-Mail Removed) uk wrote:
>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      26th Nov 2009
Not if you did not add more to it.

Show us the code you tried that does not work.


Gord Dibben MS Excel MVP

On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
<(E-Mail Removed)> wrote:

>hi i have tried the code that you recommended but i cannot get it to work
>
>"Dave Peterson" wrote:
>
>> dim wkbk2 as workbook
>> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
>>
>>
>> (E-Mail Removed) uk wrote:
>>
>> --
>>
>> Dave Peterson
>> .
>>


 
Reply With Quote
 
swain.s@blueyonder.co uk
Guest
Posts: n/a
 
      26th Nov 2009
this is a code from MACROS MADE EASY

Sub Workbook_Open()
Workbooks.Open("data.xls")
End Sub

"Gord Dibben" wrote:

> Not if you did not add more to it.
>
> Show us the code you tried that does not work.
>
>
> Gord Dibben MS Excel MVP
>
> On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
> <(E-Mail Removed)> wrote:
>
> >hi i have tried the code that you recommended but i cannot get it to work
> >
> >"Dave Peterson" wrote:
> >
> >> dim wkbk2 as workbook
> >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
> >>
> >>
> >> (E-Mail Removed) uk wrote:
> >>
> >> --
> >>
> >> Dave Peterson
> >> .
> >>

>
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      27th Nov 2009
Include the drive and path, too:

Workbooks.Open("c:\my folder\my other folder\data.xls")

(change as appropriate)

(E-Mail Removed) uk wrote:
>
> this is a code from MACROS MADE EASY
>
> Sub Workbook_Open()
> Workbooks.Open("data.xls")
> End Sub
>
> "Gord Dibben" wrote:
>
> > Not if you did not add more to it.
> >
> > Show us the code you tried that does not work.
> >
> >
> > Gord Dibben MS Excel MVP
> >
> > On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
> > <(E-Mail Removed)> wrote:
> >
> > >hi i have tried the code that you recommended but i cannot get it to work
> > >
> > >"Dave Peterson" wrote:
> > >
> > >> dim wkbk2 as workbook
> > >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
> > >>
> > >>
> > >> (E-Mail Removed) uk wrote:
> > >>
> > >> --
> > >>
> > >> Dave Peterson
> > >> .
> > >>

> >
> > .
> >


--

Dave Peterson
 
Reply With Quote
 
swain.s@blueyonder.co uk
Guest
Posts: n/a
 
      28th Nov 2009
i have tried all the codes that you have suggested and i still cant get it to
work

"Dave Peterson" wrote:

> Include the drive and path, too:
>
> Workbooks.Open("c:\my folder\my other folder\data.xls")
>
> (change as appropriate)
>
> (E-Mail Removed) uk wrote:
> >
> > this is a code from MACROS MADE EASY
> >
> > Sub Workbook_Open()
> > Workbooks.Open("data.xls")
> > End Sub
> >
> > "Gord Dibben" wrote:
> >
> > > Not if you did not add more to it.
> > >
> > > Show us the code you tried that does not work.
> > >
> > >
> > > Gord Dibben MS Excel MVP
> > >
> > > On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
> > > <(E-Mail Removed)> wrote:
> > >
> > > >hi i have tried the code that you recommended but i cannot get it to work
> > > >
> > > >"Dave Peterson" wrote:
> > > >
> > > >> dim wkbk2 as workbook
> > > >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
> > > >>
> > > >>
> > > >> (E-Mail Removed) uk wrote:
> > > >>
> > > >> --
> > > >>
> > > >> Dave Peterson
> > > >> .
> > > >>
> > >
> > > .
> > >

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      28th Nov 2009
What happens when you try it?

Do you have macros enabled?

Are you sure that the data.xls file exists in the drive/folder you specified?

How are you opening the workbook that opens the data.xls workbook?




(E-Mail Removed) uk wrote:
>
> i have tried all the codes that you have suggested and i still cant get it to
> work
>
> "Dave Peterson" wrote:
>
> > Include the drive and path, too:
> >
> > Workbooks.Open("c:\my folder\my other folder\data.xls")
> >
> > (change as appropriate)
> >
> > (E-Mail Removed) uk wrote:
> > >
> > > this is a code from MACROS MADE EASY
> > >
> > > Sub Workbook_Open()
> > > Workbooks.Open("data.xls")
> > > End Sub
> > >
> > > "Gord Dibben" wrote:
> > >
> > > > Not if you did not add more to it.
> > > >
> > > > Show us the code you tried that does not work.
> > > >
> > > >
> > > > Gord Dibben MS Excel MVP
> > > >
> > > > On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
> > > > <(E-Mail Removed)> wrote:
> > > >
> > > > >hi i have tried the code that you recommended but i cannot get it to work
> > > > >
> > > > >"Dave Peterson" wrote:
> > > > >
> > > > >> dim wkbk2 as workbook
> > > > >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
> > > > >>
> > > > >>
> > > > >> (E-Mail Removed) uk wrote:
> > > > >>
> > > > >> --
> > > > >>
> > > > >> Dave Peterson
> > > > >> .
> > > > >>
> > > >
> > > > .
> > > >

> >
> > --
> >
> > Dave Peterson
> > .
> >


--

Dave Peterson
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      28th Nov 2009
Have you inadvertantly disabled events?

Copy this to Immediate Window

Application.EnableEvents = True and hit Enter


Gord

On Sat, 28 Nov 2009 00:59:01 -0800, (E-Mail Removed) uk
<(E-Mail Removed)> wrote:

>i have tried all the codes that you have suggested and i still cant get it to
>work
>
>"Dave Peterson" wrote:
>
>> Include the drive and path, too:
>>
>> Workbooks.Open("c:\my folder\my other folder\data.xls")
>>
>> (change as appropriate)
>>
>> (E-Mail Removed) uk wrote:
>> >
>> > this is a code from MACROS MADE EASY
>> >
>> > Sub Workbook_Open()
>> > Workbooks.Open("data.xls")
>> > End Sub
>> >
>> > "Gord Dibben" wrote:
>> >
>> > > Not if you did not add more to it.
>> > >
>> > > Show us the code you tried that does not work.
>> > >
>> > >
>> > > Gord Dibben MS Excel MVP
>> > >
>> > > On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
>> > > <(E-Mail Removed)> wrote:
>> > >
>> > > >hi i have tried the code that you recommended but i cannot get it to work
>> > > >
>> > > >"Dave Peterson" wrote:
>> > > >
>> > > >> dim wkbk2 as workbook
>> > > >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
>> > > >>
>> > > >>
>> > > >> (E-Mail Removed) uk wrote:
>> > > >>
>> > > >> --
>> > > >>
>> > > >> Dave Peterson
>> > > >> .
>> > > >>
>> > >
>> > > .
>> > >

>>
>> --
>>
>> Dave Peterson
>> .
>>


 
Reply With Quote
 
swain.s@blueyonder.co uk
Guest
Posts: n/a
 
      28th Nov 2009
run time error '1004':
yes the macro is enabled when i open the 1st file security warning
yes they are both in the 'C:\ dir
i open test.xls manually and i want it to open data.xls automatically

"Dave Peterson" wrote:

> What happens when you try it?
>
> Do you have macros enabled?
>
> Are you sure that the data.xls file exists in the drive/folder you specified?
>
> How are you opening the workbook that opens the data.xls workbook?
>
>
>
>
> (E-Mail Removed) uk wrote:
> >
> > i have tried all the codes that you have suggested and i still cant get it to
> > work
> >
> > "Dave Peterson" wrote:
> >
> > > Include the drive and path, too:
> > >
> > > Workbooks.Open("c:\my folder\my other folder\data.xls")
> > >
> > > (change as appropriate)
> > >
> > > (E-Mail Removed) uk wrote:
> > > >
> > > > this is a code from MACROS MADE EASY
> > > >
> > > > Sub Workbook_Open()
> > > > Workbooks.Open("data.xls")
> > > > End Sub
> > > >
> > > > "Gord Dibben" wrote:
> > > >
> > > > > Not if you did not add more to it.
> > > > >
> > > > > Show us the code you tried that does not work.
> > > > >
> > > > >
> > > > > Gord Dibben MS Excel MVP
> > > > >
> > > > > On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
> > > > > <(E-Mail Removed)> wrote:
> > > > >
> > > > > >hi i have tried the code that you recommended but i cannot get it to work
> > > > > >
> > > > > >"Dave Peterson" wrote:
> > > > > >
> > > > > >> dim wkbk2 as workbook
> > > > > >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
> > > > > >>
> > > > > >>
> > > > > >> (E-Mail Removed) uk wrote:
> > > > > >>
> > > > > >> --
> > > > > >>
> > > > > >> Dave Peterson
> > > > > >> .
> > > > > >>
> > > > >
> > > > > .
> > > > >
> > >
> > > --
> > >
> > > Dave Peterson
> > > .
> > >

>
> --
>
> Dave Peterson
> .
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      28th Nov 2009
Record a macro when you open that file manually. Use that code in the
workbook_Open event. (I'm guessing that you have a typo in your
drive/path/filename.)

If you have trouble modifying the workbook_open, then post the complete recorded
macro.

(E-Mail Removed) uk wrote:
>
> run time error '1004':
> yes the macro is enabled when i open the 1st file security warning
> yes they are both in the 'C:\ dir
> i open test.xls manually and i want it to open data.xls automatically
>
> "Dave Peterson" wrote:
>
> > What happens when you try it?
> >
> > Do you have macros enabled?
> >
> > Are you sure that the data.xls file exists in the drive/folder you specified?
> >
> > How are you opening the workbook that opens the data.xls workbook?
> >
> >
> >
> >
> > (E-Mail Removed) uk wrote:
> > >
> > > i have tried all the codes that you have suggested and i still cant get it to
> > > work
> > >
> > > "Dave Peterson" wrote:
> > >
> > > > Include the drive and path, too:
> > > >
> > > > Workbooks.Open("c:\my folder\my other folder\data.xls")
> > > >
> > > > (change as appropriate)
> > > >
> > > > (E-Mail Removed) uk wrote:
> > > > >
> > > > > this is a code from MACROS MADE EASY
> > > > >
> > > > > Sub Workbook_Open()
> > > > > Workbooks.Open("data.xls")
> > > > > End Sub
> > > > >
> > > > > "Gord Dibben" wrote:
> > > > >
> > > > > > Not if you did not add more to it.
> > > > > >
> > > > > > Show us the code you tried that does not work.
> > > > > >
> > > > > >
> > > > > > Gord Dibben MS Excel MVP
> > > > > >
> > > > > > On Thu, 26 Nov 2009 09:20:01 -0800, (E-Mail Removed) uk
> > > > > > <(E-Mail Removed)> wrote:
> > > > > >
> > > > > > >hi i have tried the code that you recommended but i cannot get it to work
> > > > > > >
> > > > > > >"Dave Peterson" wrote:
> > > > > > >
> > > > > > >> dim wkbk2 as workbook
> > > > > > >> set wkbk2 = workbooks.open(filename:="c:\somefilename.xls")
> > > > > > >>
> > > > > > >>
> > > > > > >> (E-Mail Removed) uk wrote:
> > > > > > >>
> > > > > > >> --
> > > > > > >>
> > > > > > >> Dave Peterson
> > > > > > >> .
> > > > > > >>
> > > > > >
> > > > > > .
> > > > > >
> > > >
> > > > --
> > > >
> > > > Dave Peterson
> > > > .
> > > >

> >
> > --
> >
> > Dave Peterson
> > .
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
code to open another workbook Rob Microsoft Excel Programming 3 30th Apr 2011 08:07 PM
code to open another workbook Rob Microsoft Excel Programming 0 30th Apr 2011 03:29 AM
Re: how can i open a second workbook using a vba code Dave Peterson Microsoft Excel Misc 0 25th Nov 2009 08:13 PM
Need VB code for workbook open to open a link =?Utf-8?B?RGFuaWVsIEJha2Vy?= Microsoft Excel Misc 2 18th Aug 2006 01:30 AM
Code to open new workbook Andrew Microsoft Excel Programming 3 22nd Jan 2004 01:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:08 PM.