PC Review


Reply
Thread Tools Rate Thread

code to run once on first open after save

 
 
=?Utf-8?B?cHN3YW5pZQ==?=
Guest
Posts: n/a
 
      18th Jun 2007
i got 2 computers...
lets name computer A janphi
and computer B pswanie

i use pswanie to write and edit a workbook wich i then email a excel
workbook to janphi. with the name editinventry.xls. this i got saved in
c:\windows\myfolder

janphi has a c:\windows\myfolder\inventry.xls

i need a macro to run when janphi open the editinventry.xls from the email.
this macro then needs to copy\paste info from inventry.xls {sheet1 cell
b2} to editinventry {sheet1 cell b2}.

next step will be to save as {editinventry.xls} to
c:\windows\myfolder\inventry.xls on janphi...

this need to run once only.
 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      18th Jun 2007
pswanie,

Name a cell

RunMacro

and then put "Yes" into that cell before emailing the workbook.

In the workbook's open code, use this

Private Sub Workbook_Open()
Dim myB As Workbook
If Environ("COMPUTERNAME") = "janphi" Then
If Range("RunMacro").Value = "Yes" Then
Range("RunMacro").Value = "No"
Set myB = Workbooks.Open("C:\windows\myfolder\inventry.xls")
myB.Worksheets("Sheet1").Range("B2").Copy _
ThisWorkbook.Worksheets("Sheet1").Range("B2")
myB.Close False
Application.DisplayAlerts = False
ThisWorkbook.SaveAs "C:\windows\myfolder\inventry.xls"
Application.DisplayAlerts = True
End If
End If

End Sub

HTH,
Bernie
MS Excel MVP


"pswanie" <(E-Mail Removed)> wrote in message
news:15641392-EEB0-4BFA-B5D9-(E-Mail Removed)...
>i got 2 computers...
> lets name computer A janphi
> and computer B pswanie
>
> i use pswanie to write and edit a workbook wich i then email a excel
> workbook to janphi. with the name editinventry.xls. this i got saved in
> c:\windows\myfolder
>
> janphi has a c:\windows\myfolder\inventry.xls
>
> i need a macro to run when janphi open the editinventry.xls from the email.
> this macro then needs to copy\paste info from inventry.xls {sheet1 cell
> b2} to editinventry {sheet1 cell b2}.
>
> next step will be to save as {editinventry.xls} to
> c:\windows\myfolder\inventry.xls on janphi...
>
> this need to run once only.



 
Reply With Quote
 
=?Utf-8?B?cHN3YW5pZQ==?=
Guest
Posts: n/a
 
      18th Jun 2007
thanx... i think that is my solution but...

i got about 7 computers that i email the workbook to.. how to from there?
the macro that needs to run are named

download



"Bernie Deitrick" wrote:

> pswanie,
>
> Name a cell
>
> RunMacro
>
> and then put "Yes" into that cell before emailing the workbook.
>
> In the workbook's open code, use this
>
> Private Sub Workbook_Open()
> Dim myB As Workbook
> If Environ("COMPUTERNAME") = "janphi" Then
> If Range("RunMacro").Value = "Yes" Then
> Range("RunMacro").Value = "No"
> Set myB = Workbooks.Open("C:\windows\myfolder\inventry.xls")
> myB.Worksheets("Sheet1").Range("B2").Copy _
> ThisWorkbook.Worksheets("Sheet1").Range("B2")
> myB.Close False
> Application.DisplayAlerts = False
> ThisWorkbook.SaveAs "C:\windows\myfolder\inventry.xls"
> Application.DisplayAlerts = True
> End If
> End If
>
> End Sub
>
> HTH,
> Bernie
> MS Excel MVP
>
>
> "pswanie" <(E-Mail Removed)> wrote in message
> news:15641392-EEB0-4BFA-B5D9-(E-Mail Removed)...
> >i got 2 computers...
> > lets name computer A janphi
> > and computer B pswanie
> >
> > i use pswanie to write and edit a workbook wich i then email a excel
> > workbook to janphi. with the name editinventry.xls. this i got saved in
> > c:\windows\myfolder
> >
> > janphi has a c:\windows\myfolder\inventry.xls
> >
> > i need a macro to run when janphi open the editinventry.xls from the email.
> > this macro then needs to copy\paste info from inventry.xls {sheet1 cell
> > b2} to editinventry {sheet1 cell b2}.
> >
> > next step will be to save as {editinventry.xls} to
> > c:\windows\myfolder\inventry.xls on janphi...
> >
> > this need to run once only.

>
>
>

 
Reply With Quote
 
Bernie Deitrick
Guest
Posts: n/a
 
      18th Jun 2007
You could remove the computername check and simply use the value of "Yes" as the flag for running
the macro.

HTH,
Bernie
MS Excel MVP


"pswanie" <(E-Mail Removed)> wrote in message
news:BA02FC55-B589-4628-A19B-(E-Mail Removed)...
> thanx... i think that is my solution but...
>
> i got about 7 computers that i email the workbook to.. how to from there?
> the macro that needs to run are named
>
> download
>
>
>
> "Bernie Deitrick" wrote:
>
>> pswanie,
>>
>> Name a cell
>>
>> RunMacro
>>
>> and then put "Yes" into that cell before emailing the workbook.
>>
>> In the workbook's open code, use this
>>
>> Private Sub Workbook_Open()
>> Dim myB As Workbook
>> If Environ("COMPUTERNAME") = "janphi" Then
>> If Range("RunMacro").Value = "Yes" Then
>> Range("RunMacro").Value = "No"
>> Set myB = Workbooks.Open("C:\windows\myfolder\inventry.xls")
>> myB.Worksheets("Sheet1").Range("B2").Copy _
>> ThisWorkbook.Worksheets("Sheet1").Range("B2")
>> myB.Close False
>> Application.DisplayAlerts = False
>> ThisWorkbook.SaveAs "C:\windows\myfolder\inventry.xls"
>> Application.DisplayAlerts = True
>> End If
>> End If
>>
>> End Sub
>>
>> HTH,
>> Bernie
>> MS Excel MVP
>>
>>
>> "pswanie" <(E-Mail Removed)> wrote in message
>> news:15641392-EEB0-4BFA-B5D9-(E-Mail Removed)...
>> >i got 2 computers...
>> > lets name computer A janphi
>> > and computer B pswanie
>> >
>> > i use pswanie to write and edit a workbook wich i then email a excel
>> > workbook to janphi. with the name editinventry.xls. this i got saved in
>> > c:\windows\myfolder
>> >
>> > janphi has a c:\windows\myfolder\inventry.xls
>> >
>> > i need a macro to run when janphi open the editinventry.xls from the email.
>> > this macro then needs to copy\paste info from inventry.xls {sheet1 cell
>> > b2} to editinventry {sheet1 cell b2}.
>> >
>> > next step will be to save as {editinventry.xls} to
>> > c:\windows\myfolder\inventry.xls on janphi...
>> >
>> > this need to run once only.

>>
>>
>>



 
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
Need help with code to save/open bstevens@rock.com Microsoft Excel Programming 8 28th May 2006 01:46 PM
Code to Save As, then Open - can't figure it out! bstevens@rock.com Microsoft Excel Misc 0 25th May 2006 09:18 PM
C# Code - Can't Save After Open =?Utf-8?B?U3RldmUgQi4=?= Microsoft Powerpoint 7 24th May 2005 01:57 PM
Code to open new workbook, prompt for 'save as' name. =?Utf-8?B?TWFyaw==?= Microsoft Excel Programming 1 5th Apr 2005 10:49 PM
Open Save As Dialog in Code Larry R Harrison Jr Microsoft Excel Programming 1 9th Mar 2004 11:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:21 AM.