View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Alvin Hansen[_2_] Alvin Hansen[_2_] is offline
external usenet poster
 
Posts: 209
Default copy sheet again again

Hallo ron
Well I have done what you write to me
If i run it manuel from Run in the menu bar is working
But not if i open the file
I have this:
In Thisworkbook
Left Dropdownmenu=workbook
Right Dropdownmenu = Open
And in this window i have

Private Sub Workbook_Open()
GetData_Example1
End Sub

I did whar you write right klik on the exel icon paste the event
And as i write when i use Run its working
Best regards
Alvin
Sorry i'm a little slow in this



"Ron de Bruin" skrev:

Hi Alvin

Good morning

Sub Auto_open()
'macro name or code
End Sub

You must copy this macro in a normal module
The macro will not run if you open the file with a macro

Or use a event

Private Sub Workbook_Open()
'macro name or code
End Sub

Right click on the Excel icon next to File in the menubar
And choose View code

You are now in the Thisworkbook module
Paste the Event in this place
Alt-Q to go back to Excel
Save and close the file

Read Chip Pearson's site about Events
http://www.cpearson.com/excel/events.htm


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message ...
Sorry
I have found out what i did wrong, well I can just say that its a good thing
to read all before trying anything. It was just the reference to the
Microsoft ActiveX Data Objects 2.5 library I didn't have

Now I have this macro there can copy the sheet from a closed workbook, how
can i get this macro to run every time i open the workbook

best Regards and many many thanks for the help

I give a beer if you ever come to Denamrk

Alvin


"Ron de Bruin" skrev:

Hi Alvin

Have you copy the functions also??

Download the example Zip file on that page to test it

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Alvin Hansen" wrote in message

...
I have read some off whar has been writing here in this forum
and find theis code from
http://www.rondebruin.nl/ado.htm

the code I use is
Sub GetData_Example1()
'This Copy the range to the ActiveCell
GetData ThisWorkbook.Path & "\test.xls", "Sheet1", "A1:C5", ActiveCell,
False

'This Copy the range to the Sheet/Range you want
'GetData ThisWorkbook.Path & "\test.xls", "Sheet1", "A1:C5",
Sheets("Sheet2").Range("A1"), False

End Sub

but get an error
its stop with Getdata and the error is:

compile error
Sub or function not defined.
Can some one help

Alvin