From: Johnnyboy5 on
On 5 June, 21:22, "Rick Rothstein"
<rick.newsNO.S...(a)NO.SPAMverizon.net> wrote:
> No, the "codesheet" is not the same as a macro. A macro is placed in a
> Module (Insert/Module from the VB editor's menu bar) whereas event code
> (which is what the Workbook_Open procedure is) goes on a "codesheet"... in
> this case, the codesheet for the workbook (because it is **workbook** event
> code). When in the VB editor, look at the Project Window (it is the one with
> Sheet1, Sheet1 and other stuff in it). Do you see the entry marked
> ThisWorkbook? Double click it. That should have opened up the codesheet for
> the workbook... copy/paste the Workbook_Open code procedure into it. Next,
> save your workbook. That's it... next time you open the workbook, the
> Workbook_Open code you just copy/pasted should run (assuming you have
> enabled macros to run, that is).
>
> --
> Rick (MVP - Excel)
>
> "Johnnyboy5" <intermediatec...(a)gmail.com> wrote in message
>
> news:d8835db5-bea6-404c-9d4f-f8e1e71bfeb1(a)r27g2000yqb.googlegroups.com...
>
>
>
> > On 5 June, 17:56, Per Jessen <perjesse...(a)hotmail.com> wrote:
> >> Use this simple event code, just remember to insert it into the
> >> codesheet ThisWorkbook in the first workbook you open.
>
> >> Private Sub Workbook_Open()
> >> Workbooks.Open ("Book2.xls") ' Change as required
> >> Workbooks.Open ("Book3.xls")
> >> Workbooks.Open ("Book4.xls")
> >> End Sub
>
> >> Regards,
> >> Per
>
> >> On 5 Jun., 18:47, Johnnyboy5 <intermediatec...(a)googlemail.com> wrote:
>
> >> > I would like to repeatly open the same workbooks at the same time just
> >> > by selecting just one book and the other three or four will open with
> >> > it.
>
> >> > thanks  everyone
>
> > Hi
>
> > cant get it to work ?  is the "codesheet" the same as a macro ?
>
> > johnnyboy- Hide quoted text -
>
> - Show quoted text -

HI

just pluged in my pen stick into my works PC and it wont open the
files - coz the file drive at work is called e.g F: at home its
called G:

so the workbooks dont get found unless I manually change the drive in
the code text

hope this makes sense.

example Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
planner.xls")

Johhny
From: Rick Rothstein on
> just pluged in my pen stick into my works PC and it wont open the
> files - coz the file drive at work is called e.g F: at home its
> called G:
>
> so the workbooks dont get found unless I manually change the drive in
> the code text
>
> hope this makes sense.
>
> example Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
> planner.xls")

Are you opening the "main" workbook (the one with the code in it) from the
"pen stick" also? If so, you can use ThisWorkbook.Path to get the path to
the workbook... if that is the same directory for all files (in both the pen
stick and your work computer), then you can use that in its entirety in
place of the hard-coded path you showed in your (single) example. Or, if
everything is not in the same ultimate directory, you can "rob" the drive
letter from the front of ThisWorkbook.Path (use the Left function to do
that) and use it instead of hard-coding the letter.

--
Rick (MVP - Excel)

--
Rick (MVP - Excel)

From: Johnnyboy5 on
On 7 June, 15:03, "Rick Rothstein"
<rick.newsNO.S...(a)NO.SPAMverizon.net> wrote:
> > just pluged in my pen stick into my works PC and it wont open the
> > files - coz the file drive at work is called e.g  F:   at home its
> > called  G:
>
> > so the workbooks dont get found unless I manually change the drive in
> > the code text
>
> > hope this makes sense.
>
> > example  Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
> > planner.xls")
>
> Are you opening the "main" workbook (the one with the code in it) from the
> "pen stick" also? If so, you can use ThisWorkbook.Path to get the path to
> the workbook... if that is the same directory for all files (in both the pen
> stick and your work computer), then you can use that in its entirety in
> place of the hard-coded path you showed in your (single) example. Or, if
> everything is not in the same ultimate directory, you can "rob" the drive
> letter from the front of ThisWorkbook.Path (use the Left function to do
> that) and use it instead of hard-coding the letter.
>
> --
> Rick (MVP - Excel)
>
> --
> Rick (MVP - Excel)

thanks Rick,

Dont quite understand "rob" anyway what I have done is to rename the
pen drive letter to "X" and changed the codes to read / look for "x"
this wont conflict with home or office. But I am still interest in
what you mean by rob, how do i use the left function instead of hard
coding the letter

best wishes

Johnny
From: Johnnyboy5 on
On 7 June, 15:03, "Rick Rothstein"
<rick.newsNO.S...(a)NO.SPAMverizon.net> wrote:
> > just pluged in my pen stick into my works PC and it wont open the
> > files - coz the file drive at work is called e.g  F:   at home its
> > called  G:
>
> > so the workbooks dont get found unless I manually change the drive in
> > the code text
>
> > hope this makes sense.
>
> > example  Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
> > planner.xls")
>
> Are you opening the "main" workbook (the one with the code in it) from the
> "pen stick" also? If so, you can use ThisWorkbook.Path to get the path to
> the workbook... if that is the same directory for all files (in both the pen
> stick and your work computer), then you can use that in its entirety in
> place of the hard-coded path you showed in your (single) example. Or, if
> everything is not in the same ultimate directory, you can "rob" the drive
> letter from the front of ThisWorkbook.Path (use the Left function to do
> that) and use it instead of hard-coding the letter.
>
> --
> Rick (MVP - Excel)
>
> --
> Rick (MVP - Excel)

also can you show me an example of how you write the text.
mine is...
Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
> planner.xls")
From: Rick Rothstein on
Maybe "rob" was to casual a word to use... what I meant was "take the
relevant part of the text and use it in your code". As an example...

DriveLetter = Left(ThisWorkbook.Path, 1)
Workbooks.Open (" & DriveLetter & _
":\Direct Payments DOT\0.5 yearly payment planner.xls")

--
Rick (MVP - Excel)



"Johnnyboy5" <intermediatecare(a)gmail.com> wrote in message
news:8c0259f6-3a48-44a8-a25c-910550849cc0(a)z8g2000yqz.googlegroups.com...
> On 7 June, 15:03, "Rick Rothstein"
> <rick.newsNO.S...(a)NO.SPAMverizon.net> wrote:
>> > just pluged in my pen stick into my works PC and it wont open the
>> > files - coz the file drive at work is called e.g F: at home its
>> > called G:
>>
>> > so the workbooks dont get found unless I manually change the drive in
>> > the code text
>>
>> > hope this makes sense.
>>
>> > example Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
>> > planner.xls")
>>
>> Are you opening the "main" workbook (the one with the code in it) from
>> the
>> "pen stick" also? If so, you can use ThisWorkbook.Path to get the path to
>> the workbook... if that is the same directory for all files (in both the
>> pen
>> stick and your work computer), then you can use that in its entirety in
>> place of the hard-coded path you showed in your (single) example. Or, if
>> everything is not in the same ultimate directory, you can "rob" the drive
>> letter from the front of ThisWorkbook.Path (use the Left function to do
>> that) and use it instead of hard-coding the letter.
>>
>> --
>> Rick (MVP - Excel)
>>
>> --
>> Rick (MVP - Excel)
>
> also can you show me an example of how you write the text.
> mine is...
> Workbooks.Open ("F:\Direct Payments DOT\0.5 yearly payment
>> planner.xls")