Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Opening a Workbook

Below is the macro I am using that I have assigned to a
button that is located on a menu in Excel. I have this
macro saved in Personal.Xls.

I would like to add the code to it to check to see if
Workbook Stats Manager.xls is open, and if it is not open,
to open it from P:\Stats Manager.xls. After the workbook
is open it needs to run the following code.

Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Opening a Workbook

I haven't tested the following, but it should (mostly) work:

Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("Stats Manager.xls")
On Error GoTo 0
If wb Is Nothing Then set wb = Workbooks.Open ("P:\Stats Manager.xls")
wb.Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly

Keep in mind that if the data to be pasted was copied from Excel, most
likely your macro will clear the clipboard and leave you with nothing to
paste.

--

Vasant


"Todd Huttenstine" wrote in message
...
Below is the macro I am using that I have assigned to a
button that is located on a menu in Excel. I have this
macro saved in Personal.Xls.

I would like to add the code to it to check to see if
Workbook Stats Manager.xls is open, and if it is not open,
to open it from P:\Stats Manager.xls. After the workbook
is open it needs to run the following code.

Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 237
Default Opening a Workbook

Why would it clear the clipboard?


-----Original Message-----
I haven't tested the following, but it should (mostly)

work:

Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("Stats Manager.xls")
On Error GoTo 0
If wb Is Nothing Then set wb = Workbooks.Open ("P:\Stats

Manager.xls")
wb.Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly

Keep in mind that if the data to be pasted was copied

from Excel, most
likely your macro will clear the clipboard and leave you

with nothing to
paste.

--

Vasant


"Todd Huttenstine"

wrote in message
...
Below is the macro I am using that I have assigned to a
button that is located on a menu in Excel. I have this
macro saved in Personal.Xls.

I would like to add the code to it to check to see if
Workbook Stats Manager.xls is open, and if it is not

open,
to open it from P:\Stats Manager.xls. After the

workbook
is open it needs to run the following code.

Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Opening a Workbook

Because Excel's copy and paste is quirky and needs very little encouragement
to clear the clipboard <g. I think you just need to try it out and make
sure that there is something to paste.

--

Vasant

"Todd Huttenstine" wrote in message
...
Why would it clear the clipboard?


-----Original Message-----
I haven't tested the following, but it should (mostly)

work:

Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("Stats Manager.xls")
On Error GoTo 0
If wb Is Nothing Then set wb = Workbooks.Open ("P:\Stats

Manager.xls")
wb.Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly

Keep in mind that if the data to be pasted was copied

from Excel, most
likely your macro will clear the clipboard and leave you

with nothing to
paste.

--

Vasant


"Todd Huttenstine"

wrote in message
...
Below is the macro I am using that I have assigned to a
button that is located on a menu in Excel. I have this
macro saved in Personal.Xls.

I would like to add the code to it to check to see if
Workbook Stats Manager.xls is open, and if it is not

open,
to open it from P:\Stats Manager.xls. After the

workbook
is open it needs to run the following code.

Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly




.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Opening a Workbook

Oh I tried and it works perfectly.


-----Original Message-----
Because Excel's copy and paste is quirky and needs very

little encouragement
to clear the clipboard <g. I think you just need to try

it out and make
sure that there is something to paste.

--

Vasant

"Todd Huttenstine"

wrote in message
...
Why would it clear the clipboard?


-----Original Message-----
I haven't tested the following, but it should (mostly)

work:

Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("Stats Manager.xls")
On Error GoTo 0
If wb Is Nothing Then set wb = Workbooks.Open

("P:\Stats
Manager.xls")
wb.Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly

Keep in mind that if the data to be pasted was copied

from Excel, most
likely your macro will clear the clipboard and leave

you
with nothing to
paste.

--

Vasant


"Todd Huttenstine"


wrote in message
...
Below is the macro I am using that I have assigned

to a
button that is located on a menu in Excel. I have

this
macro saved in Personal.Xls.

I would like to add the code to it to check to see if
Workbook Stats Manager.xls is open, and if it is not

open,
to open it from P:\Stats Manager.xls. After the

workbook
is open it needs to run the following code.

Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly




.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Opening a Workbook

Good! Glad to hear it.

--

Vasant

"Todd" wrote in message
...
Oh I tried and it works perfectly.


-----Original Message-----
Because Excel's copy and paste is quirky and needs very

little encouragement
to clear the clipboard <g. I think you just need to try

it out and make
sure that there is something to paste.

--

Vasant

"Todd Huttenstine"

wrote in message
...
Why would it clear the clipboard?


-----Original Message-----
I haven't tested the following, but it should (mostly)
work:

Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks("Stats Manager.xls")
On Error GoTo 0
If wb Is Nothing Then set wb = Workbooks.Open

("P:\Stats
Manager.xls")
wb.Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly

Keep in mind that if the data to be pasted was copied
from Excel, most
likely your macro will clear the clipboard and leave

you
with nothing to
paste.

--

Vasant


"Todd Huttenstine"


wrote in message
...
Below is the macro I am using that I have assigned

to a
button that is located on a menu in Excel. I have

this
macro saved in Personal.Xls.

I would like to add the code to it to check to see if
Workbook Stats Manager.xls is open, and if it is not
open,
to open it from P:\Stats Manager.xls. After the
workbook
is open it needs to run the following code.

Worksheets(1).Range("C5").Select
ActiveSheet.Paste
MsgBox "Data Pasted!", vbOKOnly




.



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I stop blank workbook from opening when opening an existing kjg Excel Discussion (Misc queries) 3 February 12th 10 09:36 PM
when opening an Excel Workbook, another blank workbook also opens Gord Dibben Excel Discussion (Misc queries) 0 October 12th 07 09:49 PM
when opening an Excel Workbook, another blank workbook also opens spmu Excel Discussion (Misc queries) 0 October 12th 07 01:46 PM
Preventing opening workbook inside active workbook. Serge[_4_] Excel Programming 2 November 4th 03 07:51 PM
Question for Experts: Opening workbook with workbook references Chris Excel Programming 0 September 11th 03 07:05 PM


All times are GMT +1. The time now is 05:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"