Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Open file from a form

Private Sub TB_ImportIntoBook_Enter()
'MsgBox "This is enter"

Openwkb = Application.GetOpenFilename("FileToImportInto, *.xls")

Workbooks.Open (Openwkb)

TB_ImportIntoBook.Value = Openwkb

End Sub

I have the above code in a form. This code is in a text box and runs
when users enter in the text box. I can not open excel fie. If I
comment out the like "Workbooks.Open (Openwkb)" the form work fine but
also does not open the file. I want the file to open also then user
selects the file.

Can anyone help me with this. Is this possible or I am trying to do
something that is not possible.

Please let me know

Regards

Sonu.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Open file from a form

And yes I want to keep the form open. If I unload the form I can open
the file but I need to keep the form open as well.

sonu wrote:
Private Sub TB_ImportIntoBook_Enter()
'MsgBox "This is enter"

Openwkb = Application.GetOpenFilename("FileToImportInto, *.xls")

Workbooks.Open (Openwkb)

TB_ImportIntoBook.Value = Openwkb

End Sub

I have the above code in a form. This code is in a text box and runs
when users enter in the text box. I can not open excel fie. If I
comment out the like "Workbooks.Open (Openwkb)" the form work fine but
also does not open the file. I want the file to open also then user
selects the file.

Can anyone help me with this. Is this possible or I am trying to do
something that is not possible.

Please let me know

Regards

Sonu.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Open file from a form

Your code works for me. Have you tried setting a Breakpoint on the
GetOpenFilename line and stepping through the code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"sonu" wrote in message
ps.com...
Private Sub TB_ImportIntoBook_Enter()
'MsgBox "This is enter"

Openwkb = Application.GetOpenFilename("FileToImportInto, *.xls")

Workbooks.Open (Openwkb)

TB_ImportIntoBook.Value = Openwkb

End Sub

I have the above code in a form. This code is in a text box and runs
when users enter in the text box. I can not open excel fie. If I
comment out the like "Workbooks.Open (Openwkb)" the form work fine but
also does not open the file. I want the file to open also then user
selects the file.

Can anyone help me with this. Is this possible or I am trying to do
something that is not possible.

Please let me know

Regards

Sonu.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Open file from a form

Yes I did. When I set breakpoint it does not stop on it. I have to
check it with msgboxes. I have excel 2000. Did you try it in later
version.

Chip Pearson wrote:
Your code works for me. Have you tried setting a Breakpoint on the
GetOpenFilename line and stepping through the code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"sonu" wrote in message
ps.com...
Private Sub TB_ImportIntoBook_Enter()
'MsgBox "This is enter"

Openwkb = Application.GetOpenFilename("FileToImportInto, *.xls")

Workbooks.Open (Openwkb)

TB_ImportIntoBook.Value = Openwkb

End Sub

I have the above code in a form. This code is in a text box and runs
when users enter in the text box. I can not open excel fie. If I
comment out the like "Workbooks.Open (Openwkb)" the form work fine but
also does not open the file. I want the file to open also then user
selects the file.

Can anyone help me with this. Is this possible or I am trying to do
something that is not possible.

Please let me know

Regards

Sonu.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Open file from a form

I initially tried it in 2003 and it was successful. I then tried it in 2000
and it ran successfully. I'm surprised that the breakpoints didn't pause the
code. Put a Stop statement before the GetOpenFilename line. This will cause
VBA to stop on that line. Another method is to use Debug.Assert:

Debug.Assert False

The VBA code will pause execution on the Assert statement.

Once VBA is paused on the Stop or Assert statement, use F8 to step through
the code. If you have an "On Error Resume Next" in the code. remove it. You
want On Error Goto 0 to be in effect.



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"sonu" wrote in message
ups.com...
Yes I did. When I set breakpoint it does not stop on it. I have to
check it with msgboxes. I have excel 2000. Did you try it in later
version.

Chip Pearson wrote:
Your code works for me. Have you tried setting a Breakpoint on the
GetOpenFilename line and stepping through the code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"sonu" wrote in message
ps.com...
Private Sub TB_ImportIntoBook_Enter()
'MsgBox "This is enter"

Openwkb = Application.GetOpenFilename("FileToImportInto, *.xls")

Workbooks.Open (Openwkb)

TB_ImportIntoBook.Value = Openwkb

End Sub

I have the above code in a form. This code is in a text box and runs
when users enter in the text box. I can not open excel fie. If I
comment out the like "Workbooks.Open (Openwkb)" the form work fine but
also does not open the file. I want the file to open also then user
selects the file.

Can anyone help me with this. Is this possible or I am trying to do
something that is not possible.

Please let me know

Regards

Sonu.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Open file from a form

Chip,

Thanks. I got it actually I also had another control on the same fom. I
have a RefEdit box on the same form. The problem is caused by that.
Once I deleted this control box the code works fine.

I am ok for now.

Thanks for all the help. I really appreciate it.

Sonu.


Chip Pearson wrote:
I initially tried it in 2003 and it was successful. I then tried it in 2000
and it ran successfully. I'm surprised that the breakpoints didn't pause the
code. Put a Stop statement before the GetOpenFilename line. This will cause
VBA to stop on that line. Another method is to use Debug.Assert:

Debug.Assert False

The VBA code will pause execution on the Assert statement.

Once VBA is paused on the Stop or Assert statement, use F8 to step through
the code. If you have an "On Error Resume Next" in the code. remove it. You
want On Error Goto 0 to be in effect.



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)



"sonu" wrote in message
ups.com...
Yes I did. When I set breakpoint it does not stop on it. I have to
check it with msgboxes. I have excel 2000. Did you try it in later
version.

Chip Pearson wrote:
Your code works for me. Have you tried setting a Breakpoint on the
GetOpenFilename line and stepping through the code?


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"sonu" wrote in message
ps.com...
Private Sub TB_ImportIntoBook_Enter()
'MsgBox "This is enter"

Openwkb = Application.GetOpenFilename("FileToImportInto, *.xls")

Workbooks.Open (Openwkb)

TB_ImportIntoBook.Value = Openwkb

End Sub

I have the above code in a form. This code is in a text box and runs
when users enter in the text box. I can not open excel fie. If I
comment out the like "Workbooks.Open (Openwkb)" the form work fine but
also does not open the file. I want the file to open also then user
selects the file.

Can anyone help me with this. Is this possible or I am trying to do
something that is not possible.

Please let me know

Regards

Sonu.



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
VBA open file from a form jlclyde Excel Discussion (Misc queries) 3 April 27th 10 09:23 PM
Open Last Modified File form Location Kam Excel Discussion (Misc queries) 4 December 30th 09 05:47 PM
Open Form when file opened Dana Excel Discussion (Misc queries) 2 July 25th 08 04:36 PM
Open Form Automatically in Excel File Bejewell New Users to Excel 1 November 16th 05 06:18 PM
Need a psswd verification form to open when the file is opened Linking to specific cells in pivot table Excel Programming 6 May 31st 05 02:59 PM


All times are GMT +1. The time now is 03:07 AM.

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

About Us

"It's about Microsoft Excel"