Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default browse to open and save as in Excel vbs

I am using Excel2003, now I have a question during my work. I want to use
excel vbs to solve a problem, so I used the record mode to get a macro, the
question is:
How can I change the vbs code so that when I run the marco, it popup some
window message to let me to browse and choose the xls (for I have to deal
with many different .xls in the same way) I need, at the end of code, I want
a same window popup to ask me to save as. Can you provide me with an
example? Thanks very much.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default browse to open and save as in Excel vbs

Hello
See help in VBA on GetOpenFilename and GetSaveAsFilename methods.

Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls", , "File ?")
'Cancelled
If FileToOpen = False Then Exit Sub
MsgBox FileToOpen

Dim FileToSave
FileToSave = Application.GetSaveAsFilename(, "Excel Files, *.xls", , "Save
as:")
If FileToSave = False Then Exit Sub
MsgBox FileToSave

HTH
Cordially
Pascal


"seven" a écrit dans le message de news:
...
I am using Excel2003, now I have a question during my work. I want to use
excel vbs to solve a problem, so I used the record mode to get a macro,
the
question is:
How can I change the vbs code so that when I run the marco, it popup some
window message to let me to browse and choose the xls (for I have to deal
with many different .xls in the same way) I need, at the end of code, I
want
a same window popup to ask me to save as. Can you provide me with an
example? Thanks very much.



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4
Default browse to open and save as in Excel vbs

Hello, papou,
I tried your code, the open function works, however save as seems can not
get the results, eg, i open a book1 and then just save it as book2 without
any other steps, then no error information, however i can not find book2, So
would you please help more? Thank very much for your help!

"papou" wrote:

Hello
See help in VBA on GetOpenFilename and GetSaveAsFilename methods.

Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls", , "File ?")
'Cancelled
If FileToOpen = False Then Exit Sub
MsgBox FileToOpen

Dim FileToSave
FileToSave = Application.GetSaveAsFilename(, "Excel Files, *.xls", , "Save
as:")
If FileToSave = False Then Exit Sub
MsgBox FileToSave

HTH
Cordially
Pascal


"seven" a écrit dans le message de news:
...
I am using Excel2003, now I have a question during my work. I want to use
excel vbs to solve a problem, so I used the record mode to get a macro,
the
question is:
How can I change the vbs code so that when I run the marco, it popup some
window message to let me to browse and choose the xls (for I have to deal
with many different .xls in the same way) I need, at the end of code, I
want
a same window popup to ask me to save as. Can you provide me with an
example? Thanks very much.




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 31
Default browse to open and save as in Excel vbs

seven

Dim FileToOpen, FileToSave
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls", , "File ?")
'Cancelled
If FileToOpen = False Then Exit Sub
Workbooks.Open FileToOpen
FileToSave = Application.GetSaveAsFilename(, "Excel Files, *.xls", , "Save
as:")
'Cancelled
If FileToSave = False Then
Msgbox "You cancelled the save operation",VbInformation
Exit Sub
Else
ActiveWorkbook.SaveAs FileToSave
End If

HTH
Cordially
Pascal

"seven" a écrit dans le message de news:
...
Hello, papou,
I tried your code, the open function works, however save as seems can not
get the results, eg, i open a book1 and then just save it as book2 without
any other steps, then no error information, however i can not find book2,
So
would you please help more? Thank very much for your help!

"papou" wrote:

Hello
See help in VBA on GetOpenFilename and GetSaveAsFilename methods.

Dim FileToOpen
FileToOpen = Application.GetOpenFilename("Excel Files, *.xls", , "File
?")
'Cancelled
If FileToOpen = False Then Exit Sub
MsgBox FileToOpen

Dim FileToSave
FileToSave = Application.GetSaveAsFilename(, "Excel Files, *.xls", ,
"Save
as:")
If FileToSave = False Then Exit Sub
MsgBox FileToSave

HTH
Cordially
Pascal


"seven" a écrit dans le message de
news:
...
I am using Excel2003, now I have a question during my work. I want to
use
excel vbs to solve a problem, so I used the record mode to get a macro,
the
question is:
How can I change the vbs code so that when I run the marco, it popup
some
window message to let me to browse and choose the xls (for I have to
deal
with many different .xls in the same way) I need, at the end of code, I
want
a same window popup to ask me to save as. Can you provide me with an
example? Thanks very much.






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
excel prob - cant save worksheet if someone has it open in a veiwe Stephen Excel Discussion (Misc queries) 1 June 18th 07 05:06 AM
excel prob - cant save worksheet if someone has it open in a veiwe Stephen Excel Worksheet Functions 1 June 17th 07 10:02 AM
How do i save all open files in excel at once? ved_rocker Excel Discussion (Misc queries) 2 February 16th 06 10:11 PM
Need to browse 100's of file TITLES in Excel 2000 jeffbro27707 Excel Discussion (Misc queries) 3 May 2nd 05 08:46 PM
Excel 2003 Viewer: No more "Browse in same window" IE functionality? [email protected] Excel Discussion (Misc queries) 0 December 28th 04 07:28 PM


All times are GMT +1. The time now is 11:52 PM.

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"