View Single Post
  #1   Report Post  
Dave Peterson
 
Posts: n/a
Default

With "price chart template.xls" already open...

Option Explicit
sub Auto_open
dim tempWks as worksheet
set tempwks = nothing
on error resume next
set tempwks = workbooks("price chart template.xls").worksheets(1)
on error goto 0

if tempwks is nothing then
msgbox "Please open the template workbook!"
else
thisworkbook.worksheets(1).range("a1:b2").copy _
destination:=tempwks.range("a1")
end if

thisworkbook.close savechanges:=false
end sub

=========
But this means you have to do something special when you want to open this file
-- just for normal changes.

You can open the workbook with macros disabled or hold down the shift key while
you're opening this workbook.


David P. wrote:

I am hoping to create a macro that upon opening a file it will do the
following:

1)Copy A1:B:2 (just as an example; also - there is only one worksheet in
this file)
2)Activate Workbook "Price Chart Template" (only 1 sheet here too)
3)Paste on A:1
4)Go back to the original document and close it without saving (this is
where I'm wondering if code can allow to close the document it is written
in???)

Thank you.
--
David P.


--

Dave Peterson