ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   open file (https://www.excelbanter.com/excel-programming/370752-open-file.html)

enyaw

open file
 
I want to create a code that at the press of a button will allow the user to
search for a file and open it. When the file is open I want to be able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?

NickHK

open file
 
You can start with Application.getOpenFilename.
Once you have opened file, record a macro of your step.
Put them together and lets us if it's working.

NickHK

"enyaw" wrote in message
...
I want to create a code that at the press of a button will allow the user

to
search for a file and open it. When the file is open I want to be able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?




enyaw

open file
 
I want to be able to open any file. The code "Application.getOpenFilename"
only opens the open file window but i cannot open any of the files from
there. The excel workbook that will use this code is a sort of template that
has a user form allowing to add and edit the data. After the user opens the
file i want to be able to automatically copy the contents of that file into
the template.

"NickHK" wrote:

You can start with Application.getOpenFilename.
Once you have opened file, record a macro of your step.
Put them together and lets us if it's working.

NickHK

"enyaw" wrote in message
...
I want to create a code that at the press of a button will allow the user

to
search for a file and open it. When the file is open I want to be able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?





NickHK

open file
 
"Application.GetOpenFilename" allows you to get the path/filename of any
file.
You then have to .Open (or do whatever you want) the file yourself.
The Help file has an example.

NickHK

"enyaw" wrote in message
...
I want to be able to open any file. The code

"Application.getOpenFilename"
only opens the open file window but i cannot open any of the files from
there. The excel workbook that will use this code is a sort of template

that
has a user form allowing to add and edit the data. After the user opens

the
file i want to be able to automatically copy the contents of that file

into
the template.

"NickHK" wrote:

You can start with Application.getOpenFilename.
Once you have opened file, record a macro of your step.
Put them together and lets us if it's working.

NickHK

"enyaw" wrote in message
...
I want to create a code that at the press of a button will allow the

user
to
search for a file and open it. When the file is open I want to be

able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?







enyaw

open file
 
i used "Application.FindFile" to open the other file. Is there any way of
copying the information from the open file into the template after the file
is found? I want to be able to open the file copy the information into the
template and and close the file at the touch of a button. The filename will
not be the same which is what is making it difficult for me.

"NickHK" wrote:

"Application.GetOpenFilename" allows you to get the path/filename of any
file.
You then have to .Open (or do whatever you want) the file yourself.
The Help file has an example.

NickHK

"enyaw" wrote in message
...
I want to be able to open any file. The code

"Application.getOpenFilename"
only opens the open file window but i cannot open any of the files from
there. The excel workbook that will use this code is a sort of template

that
has a user form allowing to add and edit the data. After the user opens

the
file i want to be able to automatically copy the contents of that file

into
the template.

"NickHK" wrote:

You can start with Application.getOpenFilename.
Once you have opened file, record a macro of your step.
Put them together and lets us if it's working.

NickHK

"enyaw" wrote in message
...
I want to create a code that at the press of a button will allow the

user
to
search for a file and open it. When the file is open I want to be

able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?







NickHK

open file
 
Yes, recorder a macro of your copy actions and add it after the .FindFile
code.

NickHK

"enyaw" wrote in message
...
i used "Application.FindFile" to open the other file. Is there any way of
copying the information from the open file into the template after the

file
is found? I want to be able to open the file copy the information into

the
template and and close the file at the touch of a button. The filename

will
not be the same which is what is making it difficult for me.

"NickHK" wrote:

"Application.GetOpenFilename" allows you to get the path/filename of any
file.
You then have to .Open (or do whatever you want) the file yourself.
The Help file has an example.

NickHK

"enyaw" wrote in message
...
I want to be able to open any file. The code

"Application.getOpenFilename"
only opens the open file window but i cannot open any of the files

from
there. The excel workbook that will use this code is a sort of

template
that
has a user form allowing to add and edit the data. After the user

opens
the
file i want to be able to automatically copy the contents of that file

into
the template.

"NickHK" wrote:

You can start with Application.getOpenFilename.
Once you have opened file, record a macro of your step.
Put them together and lets us if it's working.

NickHK

"enyaw" wrote in message
...
I want to create a code that at the press of a button will allow

the
user
to
search for a file and open it. When the file is open I want to be

able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?









enyaw

open file
 
This is my code so far.
Private Sub CommandButton19_Click()
Application.FindFile
UserForm1.Hide
ActiveSheet.Unprotect
Cells.Select
Selection.Copy
ActiveWorkbook.Close savechanges:=False
Windows("Product Calculator1.xls").Activate
ActiveSheet.Unprotect
range("A1").Select
ActiveSheet.Paste
range("A1").Select
Application.CutCopyMode = False
ActiveSheet.Protect Password:="abcd"
range("A2").Select
End Sub

It stops running at "ActiveSheet.Paste". Also it as do i want to keep the
info on the clipboard. How can i stop this and get the code working?


"NickHK" wrote:

Yes, recorder a macro of your copy actions and add it after the .FindFile
code.

NickHK

"enyaw" wrote in message
...
i used "Application.FindFile" to open the other file. Is there any way of
copying the information from the open file into the template after the

file
is found? I want to be able to open the file copy the information into

the
template and and close the file at the touch of a button. The filename

will
not be the same which is what is making it difficult for me.

"NickHK" wrote:

"Application.GetOpenFilename" allows you to get the path/filename of any
file.
You then have to .Open (or do whatever you want) the file yourself.
The Help file has an example.

NickHK

"enyaw" wrote in message
...
I want to be able to open any file. The code
"Application.getOpenFilename"
only opens the open file window but i cannot open any of the files

from
there. The excel workbook that will use this code is a sort of

template
that
has a user form allowing to add and edit the data. After the user

opens
the
file i want to be able to automatically copy the contents of that file
into
the template.

"NickHK" wrote:

You can start with Application.getOpenFilename.
Once you have opened file, record a macro of your step.
Put them together and lets us if it's working.

NickHK

"enyaw" wrote in message
...
I want to create a code that at the press of a button will allow

the
user
to
search for a file and open it. When the file is open I want to be
able to
copy the contents of sheet1 into another workbook called "product
calculator". Anybody got any ideas?










enyaw

open file
 
I got the program working but i need some help. The code i have doesnt close
the workbook i am copying from. Can you help?

Private Sub CommandButton19_Click()
Application.FindFile
UserForm1.Hide
Cells.Select
Selection.Copy
Windows("Product Calculator1.xls").Activate
Sheets("Sheet2").Activate
ActiveSheet.Unprotect Password:="abcd"
range("A1").Select
ActiveSheet.Paste
range("A1").Select
ActiveSheet.Protect Password:="abcd"
Application.CutCopyMode = False
range("A2").Select
End Sub

"enyaw" wrote:


Jean-Yves[_2_]

open file
 
In your last mnail, one line got missing
ActiveWorkbook.Close savechanges:=False
Regards
JY

"enyaw" wrote in message
...
I got the program working but i need some help. The code i have doesnt
close
the workbook i am copying from. Can you help?

Private Sub CommandButton19_Click()
Application.FindFile
UserForm1.Hide
Cells.Select
Selection.Copy
Windows("Product Calculator1.xls").Activate
Sheets("Sheet2").Activate
ActiveSheet.Unprotect Password:="abcd"
range("A1").Select
ActiveSheet.Paste
range("A1").Select
ActiveSheet.Protect Password:="abcd"
Application.CutCopyMode = False
range("A2").Select
End Sub

"enyaw" wrote:





All times are GMT +1. The time now is 12:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com