[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB6 File "Save As" routine

Posted on 2007-10-17
12
Medium Priority
?
1,123 Views
Last Modified: 2008-01-09
I know how to do a File -> Save... and I have code to do File -> Save As and prompt user for file name and location....

But in most applications, if you do a "save as" the result is that the version you were in is closed and you are not "working in the new save as file"...  My program is not set up that way.... My program just saves a copy of the eixsting file off to the filename and location specifed from the dialog... it then does not "switch to that file" which has caused some confusion...

Can anyone provide any pointers in this area?  I have searched EE and Google and not found anything on:
- the correct expected procedure
- coding hints to implement that

Some type of work flow in general plus code tips is what I need... My "brute force" thought is just:
- user working in File 1
- does Save As to File2
- date from File 1 is copied and saved into File 2 on the hard drive
- File 1 is then "closed"
- File 2 is then "opened"

Thoughts?  Help?  Suggestions?
-Tim
0
Comment
Question by:torrid333
11 Comments
 
LVL 18

Expert Comment

by:Crash2100
ID: 20098258
What type of file are you working with?  Just a simple text file?
0
 
LVL 22

Accepted Solution

by:
danaseaman earned 2000 total points
ID: 20098290
I don't think you need to reload after a Save As since the contents of File2 is already correct in memory and your intention is to leave File1 unchanged on disk.

Try using a variable such as m_FileName for the filename.
Dim  m_FileName As String

The sequence would then be something like this:

1. Open File1 - Set m_FileName to the name. Read File1. Close File1.
2. If you hit Save then m_FileName is used and the file is updated on disk.
3. If you hit Save As then save with new name File2. Set m_FileName to this new name.
0
 

Author Comment

by:torrid333
ID: 20098420
Hmmm I'll have to double check but I'm not 100% sure I close the file after opening and reading the data....  I think it stays open until you close or exit the program....  

Using what you suggest... the file would be closed after opening and reading... then if saved... I would actually open the file and save it again... using the filename/path I have stored... so same deal with save as...

When I open and read a file am I supposed to set seomthing that prevents others from opening and using same file?  I see word creating these ~filename entries in same folder which I think is used to protect from multiple users editing???
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:torrid333
ID: 20098423
Crash
The file is actually a binary file that I save and load UDTs from.
0
 
LVL 22

Expert Comment

by:danaseaman
ID: 20098467
Once you read the File there would be no need to keep it open.

Since the file is always closed others could open and modify it but then when you save it overwrites with new changes you have made or better yet use Save As to create a new FileName.

As to Word ~filename entries I think that is in case you use "Save" which would normally overwrite the original but in this case they make a copy of original as "~filename" so that you could recover the original if needed.
0
 

Author Comment

by:torrid333
ID: 20294688
Quick adjunct to this question.... danaseaman.. related to the "~filename" directory entries... I thought those were just placeholders to PREVENT multiple users editing a file.... so on open you check for ~filename and if it exists then don't allow user to open it.  And on close you delete ~filename. ????  In the case of Word I have not seen that the ~ files contain anything so I thought it was real basic mutli-user edit prevention....

Do you know anything about this?  Most of our users are not sharing files but a few of them are trying to share data files over a server....
0
 

Author Comment

by:torrid333
ID: 20298267
Quick adjunct to this question.... danaseaman.. related to the "~filename" directory entries... I thought those were just placeholders to PREVENT multiple users editing a file.... so on open you check for ~filename and if it exists then don't allow user to open it.  And on close you delete ~filename. ????  In the case of Word I have not seen that the ~ files contain anything so I thought it was real basic mutli-user edit prevention....

Do you know anything about this?  Most of our users are not sharing files but a few of them are trying to share data files over a server....
0
 

Author Comment

by:torrid333
ID: 20299892
Quick adjunct to this question.... danaseaman.. related to the "~filename" directory entries... I thought those were just placeholders to PREVENT multiple users editing a file.... so on open you check for ~filename and if it exists then don't allow user to open it.  And on close you delete ~filename. ????  In the case of Word I have not seen that the ~ files contain anything so I thought it was real basic mutli-user edit prevention....

Do you know anything about this?  Most of our users are not sharing files but a few of them are trying to share data files over a server....
0
 

Author Comment

by:torrid333
ID: 20299904
for some reason every time I view this page it reposts the same comment... dont know why it's doing that... thanks danaseaman I'll look at that later when I get the time.... -Tim
0
 
LVL 5

Expert Comment

by:Netminder
ID: 20303543
torrid333,

Can you please post some details about your system (OS and browser, any firewall or proxy information) here: http:/Q_22966357.html.

DanRollins has kindly posted the above question so we can figure out what's going on with your posts.

Netminder
Site Admin
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month19 days, 7 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question