Why Text File Not Saved Occassionally
Hello. I use a richtextbox to document our services to our clients. The textbox is saved in textfile. It does not save may be once in a few hundred times that I hit Save. Usually I hit Save and exit, believing that the document is saved. When return to that document, the textbox is blank sometimes, or sometimes only a newly added portion of the document is not there. Keep in mind, this happens only once in a few hundred times of saving the file, or once or twice a year. Does that have to do with memory for some reason? or what? I don't see anything wrong with the code. Below is my code for loading and saving. Please review and give me any advice. Thank you.
VB6:
Code: Private Sub ShowText() 'This line is needed to load a textfile name and save the file. Get MainFileNumber, CurrentRecordPosition, mRecord LblChildName2.Caption = Trim(mRecord.FirstName) + " " + UCase(Trim(mRecord.LastName)) LblParents2.Caption = Trim(mRecord.Parents) LblClass2.Caption = Trim(mRecord.Class) + " -- " + Trim(mRecord.Teacher) LblPhone2.Caption = Trim(mRecord.Phone)
' FSLogFileName is declared as string in Module FSLogFileName = WorkingFilePath & "" & Trim(mRecord.RecordID) & "-Servicelog.txt"
Dim FindFilename As String FindFilename = Dir$(FSLogFileName) If FindFilename = "" Then ' Createfile if file does not exist RichTextBox1.Text = "" file ' RichTextBox1.LoadFile FSLogFileName Else ' If filename was found, read record RichTextBox1.LoadFile FSLogFileName ' Format to load Richtext file End If
' Brings cursor to the end of text If Len(Trim(RichTextBox1.Text)) > 300 Then RichTextBox1.SelStart = Len(Trim(RichTextBox1.Text)) End If End Sub
Private Sub Save()
FSLogFileName = WorkingFilePath & "" & Trim(mRecord.RecordID) & "-Servicelog.txt" RichTextBox1.SaveFile FSLogFileName, rtfRTF ' Save file
End Sub
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How Can I Use A Specified Information Saved In A Text File?
I have a program that uses this code to write the info entered by the user in a text file:
Quote:
Private Sub Command1_Click()
n = Text1.Text
a = Text2.Text
Open "h:RECORDS.txt" For Append As #7
Write #7, n, a
Close #7
MsgBox "Done!"
End Sub
I am using this code to put the first field (na) of info of the text file in a combobox:
Quote:
Private Sub Command2_Click()
Open "h:RECORDS.txt" For Input As #3
Do While Not EOF(3)
Input #3, na, ag
Combo1.AddItem na
Loop
Close #3
How can I make my program so it only goes to the next form (ex. form2) when the second field of info (ag) in the text file is entered in the second textbox (a)?
Saved Text File Not Centered
I have a rich text box that has centered text in it, and I save it, but when I open it up and put it back in the text box it is not centered, and when I print the text it is not centered. What is wrong?
Reading Uncode Saved Text File
i have a text file saved in unicode format (i needed to use 3 different langs there). how do i read the file and display text.
i guess i'd need to show it in RichTextBox, but if i just use Line Input and do RichTextBox.text= , then it just shows me like if i'd open it in notepad...
so, what do i need to do
TIA!
Changing The Saved Info In A Text File
Let's say for example, some info's been saved using this code:
Open "C:Textfile.txt" For Append As #3
Write #3, Text1, Text2, Combo1.text, List1.text
Close #3
and the text file is something like:
Code:
"James", "16", "Green", "1990"
"Bob", "20", "Red", "1980"
How can change an specific info in the text file? (For example, the user enters "Bob" as his name in my program and changes "Red" to something else in a combobox. So i need the computer to find "Bob" in the text file and change "Red" to something the user enters in my program.)
If any more info is required, tell me and i will add.
Asap & thnk you
Multiple TextBox's Saved To Text File
Hi, Please help.
I am creating a form in VB6 that has three textbox's and a "save" commandBox.
I would like the save box to take the information in the three textbox's and place them in a text file (c: est.text [for discusion purposes]), then clear the fields ready for the next information. Then when save is clicked again it "adds" the information to the text already in the test.txt file.
Thanks in advance for any help that may be offered.
Checkbox State Saved To Sequential Text File
I need to save the state of some checkboxes to a sequential textfile. I am getting a type mismatch when I read the state back out of the file as a string(true or false) and try to assign it to the checkbox on my form. What type of Variable should I be using?
Here is what I'm trying.....
To get the state from the form:
dim FL as string
if checkFL.value then
FL$="true"
else: FL$="false"
end if
Once ive read the file and retreived it as a string, to assign it back to the checkbox:
checkFL.value = FL$
- this statement gives me a type mismatch when run. How should this be done?
Much Thanks for the help......Larry
Program Occassionally Not Unloading Properly
my project consists of an MDI form, and a bunch of other forms (not all are MDI childs). occassionally, however, the program doesn't unload properly (ie. i have to use ctrl+alt+del to close it).
i have this code in the MDI form module
VB Code:
Private Sub MDIForm_Unload(Cancel As Integer) Dim frm As Form For Each frm In Forms Unload frm Set frm = Nothing NextEnd Sub
but my users are saying that it still sometimes doesn't close properly. any ideas, or could this just be something to do with windows that's beyond my control?
VB Service Occassionally Hangs In 'Stopping' Mode
I have written a VB 6.0 application that is running as a service using the NTSVC.OCX control. Occasionally, when I try to stop the service, it seems to hang, displaying a message that the service is not responding. The service indicates that it is 'stopping' when you look at the services control panel. What are some things that I can do to prevent this error from happening. The service_stop function is fairly straightforward in that it just cleans up some connections into a document management system and displays some messages to a log file. I also call 'NET STOP servicename' command. Any thoughts would be great!!
Thanks.
Spacing Out Between Saved Text...
How can I add a space between lines in a text file when user is saving it?
My code:
cboHome.Text & " to "; txtVisitors.Text & ". "; txtScore.Text; " score."
So once user enters text into those it saves into a file but in 1 line. How can I make it so there is space between each line?
Bold Text Moves To Saved Txt?
ok guys see if you can figer this one out
i save a file to whatever.doc but its not saveing the formatting to the new file the bold text impaticaler
i use a true text box and i select text and hit a butten to bold the text selected.
this code runs
Code:
Private Sub cmdhighlight_Click()
rtbMdcDisplay.SelBold = True
End Sub
that makes the text bold then i save it to a .doc file
Code:
Private Sub Command1_Click()
On Error GoTo hell
Open Dir1.Path & "" & Text1.Text & ".doc" For Output As #1
Print #1, FrmTxtWindow.RtbFileVeiw.Text
Close #1
valuelabel.Caption = Dir1.Path & "" & Text1.Text & ".doc"
FrmTxtWindow.Enabled = True
frmSaveAs.Hide
Exit Sub
hell:
MsgBox Err.Description, vbCritical, Err.Number
End Sub
but then i open the doc file in word and all the formatting is gone only thing right is each line is on the right line.
so this text
this is a test normal
this is a test bold
comes up in word as
this is a test normal
this is a test bold
i hope you understand what i mean.. please help
thanks in advance
Using Wordpad With VB Saved Text Files
I have a program in which I save TXT files using Write (VB 3.0). I then have users connect to Wordpad to avoid a lot of printer issues via a selection in my program which auto opens the file.
My problem is twofold. Wordpad doesn't save page attributes for formatting such as margins or orientation.
Second, I need to insert a Page Break character in my file with the Write command at certain points. How do I do this, and how will wordpad handle them?
Any ideas. Many thanks....
Loading Saved Text From Resource
here's the deal, i have loaded icons and text into a resource file... i can get at the icons alright but i have no idea how to load the strings from it.
the string index is 101, if this helps. its to load it into a text box.
Any relitive answer is welcome
thnx
Why RTF File Cannot Be Saved As A Real RTF File When I Use FileFormat:= FormatRTF
Using wdFormatRTF gives me headach because everytime I execute the program, a message saying "6.htm is locked" appears.
The file extention RTF does not mean it is a real RTF because when I change .rtf to .txt, I get gobbledegook while real rtf shows me rtf tags.
Why cann't the below code convert html to rtf?
'//////////////////////////////////////
Private Sub Comman1_Click_Click()
Dim w As Object
Set w = CreateObject("Word.Application")
w.Visible = False
w.Documents.Open ("D:MyFolder6.html")
w.ActiveDocument.SaveAs ("D:MyFolder6.rtf"), _
FileFormat:=FormatRTF
w.Quit
Set w = Nothing
End Sub
'///////////////////////////////////////
How To Name A File Being Saved By VBA
Hi All
I have the following code that emails a sheet for me
Code:
With ActiveWorkbook
.SendMail Recipients:="email", _
Subject:="test email"
.Close SaveChanges:=False
End With
Is there code that can pull information from the file like a cell ref to put in the subject field?
or can a msgbox popup to ask for the subject?
Thanks
Columbo
Last File Saved
I am looking for a way to determine the last file saved on a windows system.
I have reviewed extensive information about MRUs and the File System Object but have yet to come up with anything. Essentially I want to be able to automate zip compression of files save by any application via a vb application that monitors change to the FSO. Any help would be much appreciated
Need A Code That Alowes Entries In Text Boxes To Be Saved
Hi,
I am very new to VB..
I'm hoping some of you might be able to help me make a code to apply in text boxes made in MS Word 2000..
I have made a document with several text boxes, and saved it as a web page.
When I open the document in IE, I can add text in the boxes, and print it out.
What I would like is to be able to save the webpage with the entered text still in the boxes...
When I save now, and reopen, the boxes are empty..
Any hints?
Brgds André
Contents Of Datacombo Box Not Saved While All Others Are Saved!
Hi,
I have a form that has text boxes,datacombo's and date picker controls.when i try to save anew record,the contents of the datacombo boxes are not saved here's the code i use
Code:
With Adoproject.Recordset
.AddNew
!PROJCODE = Text1
!CLIENTname = DataCombo1
!contact = Text4
!PROJTITLE = Text2
!PROJSTAT = List1
!StartDate = DTPicker1
!EndDate = DTPicker2
!budgetedexp = Text9
!Leader = DataCombo2
!budgetedhrs = Text11
.Update
End With
Copy Temp File To Saved File.
Hi all.
Can someone please have a quick look over the code below and tell me where I'm going wrong. Basically I want to have the programcopy the contents of a file that is updated at runtime to a saved file when I click saveas or save.
I know that
Code:
Open CommonDialog1.Dir & CommonDialog1.FileName For Output As #filenum
is not correct. I don't know how to call up the info that's just been entered into the saveas common dialog.
And will it work if this is corrected?
VB Code:
Sub Save() Dim buff As String Dim filenum As Integer On Error Resume Next filenum = FreeFile Open App.Path & " emp.ps" For Input As #1 Open CommonDialog1.Dir & CommonDialog1.FileName For Output As #filenum Do Until EOF(1) Line Input #1, buff Print #filenum, buff Loop Close #1 Close filenum End Sub
Printing A Saved File
Is there any way of printing a saved file.
I know I can print to a file and a printer with:
print #1, first line
print first line
print #1, second line
print second line
print #1, third line
print third line
print #1, forth line
print forth line
etc...
Is there some way of calling up a file, then print it.
eq
dim MyFile as string
MyFile = "Output.doc"
Open MyFile For Output As #1
print #1, first line
print #1, second line
print #1, third line
print #1, forth line
etc...
close #1
Print MyFile
and have the contents of MyFile, that were just inputed, printed out.
Any help is appreciated.
Thanks.
Opening A Saved File On A Zip
I am trying to open a saved file on my zip disk and am not having much success. It is an Outlook Express message and is
E:file_name.eml. How do I code this?
Open E:file_name.eml. or what? It is just a button on a form and working within Excel. This will work for any file, I think. Thanks in advance
Copy A File Being Saved
hello to all !
my problem is that im generating an excel file and right after i save the file i use FSO.filecopy but sent me the following error "Permision denied" but if i run it step by step there is no error message. How can i give time to the file to be saved or check that before i copy that file ??
thanks for your help
Mxls.Application.ActiveWorkbook.SaveAs (sourcefile)
Mxls.Application.Quit
FileCopy sourcefile, targetfile
Clearing A Saved File
Is it possible to do this......
When you click on cmdsave it will first clear all info in the file then save it to it??
i have a game where it saves your spot but if i save it and then go back and save in a diffrent spot it will put the picture in to place the starting one and the last one??
is it possible to clear the file??
Last Saved File Path
In vb 6.0, how do I get a directly list box to display the last opened/saved file path. Any help is appreciated.
How To Tell If A File Saved Correctly
hi all How can i tell if a file saved correctly from a picture box please
I use this code to save it,how can I find out if it saved correctly please.
VB Code:
SavePicture Picture1.Image, strfullpath
many thanks Chrisio
How Do I Assign A Name To A Saved File?
I am new to text file processing in VB. I am parsing a file that contains many reports. I wish to save each report as a separate text file. What is the syntax for that?
Thanks,
Jeff
Opening A Saved File
any one know how to open a file that has Command button settings?
I have 77 buttons and need to save their settings.
I have saved the settings as following:
Write #1,But.tag,but.caption,but.value, but.tooltiptext
Thats all one line
but i have 77 lines, one for each button.
Have tried but the VB Examples do not help with what i am going.
need a button that will open a file, and put the Tag,Caption,Value,Tooltiptext into the buttons
thank you
Opening A Saved File
any one know how to open a file that has Command button settings?
I have 77 buttons and need to save their settings.
I have saved the settings as following:
Write #1,But.tag,but.caption,but.value, but.tooltiptext
Thats all one line
but i have 77 lines, one for each button.
Have tried but the VB Examples do not help with what i am going.
need a button that will open a file, and put the Tag,Caption,Value,Tooltiptext into the buttons
thank you
HELP, No Way To OPEN Saved File
Hi,
Let's see if I'm correct on this first.
so you have a file that has 77 lines?
each line contains button?.something,button?.something, andonand on..
and you can get all that info into a file?
hope you are familiar with following commands:
open
line input
instr
I haven't tested this thingy but try it out.. let me know if it works (ays@altavista.net)
Code:
Dim tooltiptext(1 To 77), tag(1 To 77), caption(1 To 77) As String, value(1 To 77) As whateverneed
Private Sub load_infos()
Dim filename As String
Dim currentline As Integer
currentline = 1
Open filename For Input As #1 'Open file
Do While Not (EOF(1)) 'Loop to the end of the file
Line Input #1, intemp 'Read one line from the file to the variable intemp
tag(currentline) = Left(intemp, InStr(intemp, ",")) 'Extract tag from the line
temp = Right(intemp, Len(intemp) - InStr(intemp, ","))
caption(currentline) = Left(intemp, InStr(intemp, ",")) 'Extract caption from the line
temp = Right(intemp, Len(intemp) - InStr(intemp, ","))
value(currentline) = Left(intemp, InStr(intemp, ",")) 'Extract value from the line, I don't know what you are using but I haven't seen this..
temp = Right(intemp, Len(intemp) - InStr(intemp, ","))
tooltiptext(currentline) = Left(intemp, Len(intemp)) 'Extract tooltiptext from the line
currentline = currentline + 1
Loop ' end loop
Close #1 'close file
End Sub
That is just an example, I don't promise that it works or anything (should). After that you have to program how to put the information on the arrays into the buttons.
------------------
-Matti Kiviranta
AyS of AyS Systems
(PGP protected
HELP, No Way To OPEN Saved File
Hi,
Let's see if I'm correct on this first.
so you have a file that has 77 lines?
each line contains button?.something,button?.something, andonand on..
and you can get all that info into a file?
hope you are familiar with following commands:
open
line input
instr
I haven't tested this thingy but try it out.. let me know if it works (ays@altavista.net)
Code:
Dim tooltiptext(1 To 77), tag(1 To 77), caption(1 To 77) As String, value(1 To 77) As whateverneed
Private Sub load_infos()
Dim filename As String
Dim currentline As Integer
currentline = 1
Open filename For Input As #1 'Open file
Do While Not (EOF(1)) 'Loop to the end of the file
Line Input #1, intemp 'Read one line from the file to the variable intemp
tag(currentline) = Left(intemp, InStr(intemp, ",")) 'Extract tag from the line
temp = Right(intemp, Len(intemp) - InStr(intemp, ","))
caption(currentline) = Left(intemp, InStr(intemp, ",")) 'Extract caption from the line
temp = Right(intemp, Len(intemp) - InStr(intemp, ","))
value(currentline) = Left(intemp, InStr(intemp, ",")) 'Extract value from the line, I don't know what you are using but I haven't seen this..
temp = Right(intemp, Len(intemp) - InStr(intemp, ","))
tooltiptext(currentline) = Left(intemp, Len(intemp)) 'Extract tooltiptext from the line
currentline = currentline + 1
Loop ' end loop
Close #1 'close file
End Sub
That is just an example, I don't promise that it works or anything (should). After that you have to program how to put the information on the arrays into the buttons.
------------------
-Matti Kiviranta
AyS of AyS Systems
(PGP protected
Only Last Line Is Saved In A .txt File
i have this code
Code:For i = 0 To MAX_DATA
TempZip(i) = ConvertHex(UpperLimit(i), 2) ' 4digit
TempData(i) = Zone(i)
strRet = CreateRecord(TempZip(i), TempData(i), Start, bEOF = True)
Open App.Path & "zone.txt" For Output As #1
Line Input #1, lineOfText$
If lineOfText$ = ":00000001FF" Then
Write #1, strRet
End If
Close #1
Next i
I want my zone.txt to be open and find the line :00000001FF then after finding line
I want to insert a series of lines before :00000001FF but what happened is it deletes all the files inside .txt
why is it like this can u help me debug my file? thanks
another one i tried this code
Code: For i = 0 To MAX_DATA
TempZip(i) = ConvertHex(UpperLimit(i), 2) ' 4digit
TempData(i) = Zone(i)
strRet = CreateRecord(TempZip(i), TempData(i), Start, bEOF = True)
Open App.Path & "zone.txt" For Output As #1
Write #1, strRet
Close #1
next i
only the last line of strRet is saved i dont know the problem...please help!!!
Problem Read From A Saved File
Hi, all
By using iNet, i have download the souce code of a website into a rich textbox. And then save the souce code into a text file "index.txt", then i try to read from the index.txt using Line Input #1, strLine, but it seems go through the whole file once.
the codes are:
webcontent.Text = Inet1.OpenURL("www.sina.com")
Call webcontent.SaveFile(STemp_directory + "index.txt", 1)
Open STemp_directory + "index.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine
'do something here to interpret the html codes
....
Loop
Close #1
It supposed to take lots of round to read from the file inside the loop, but it seems read the whole file into strLine once.
Anybody can give me some suggestions? the index.txt is attached
thanks a lot
dejie
Trouble With Combo Box && Saved File
I'm teaching myself VB 6 (and it's going kinda slow) and I am having some trouble.
Here is my current code:
Code:
Private Sub mnuFileSaveAs_Click()
Dim intFile As Integer
Dim strFileName As String
intFile = FreeFile
dbDialog.Filter = "Text File (*.txt)|*.txt"
dbDialog.ShowSave
dbDialog.CancelError = True
On Error GoTo dbErrHandler
strFileName = dbDialog.FileName
Open strFileName For Output As #intFile
Write #intFile, cboHeight.Text
Write #intFile, cboWeight.Text
Close #intFile
dbErrHandler:
Exit Sub
End Sub
Private Sub mnuFileOpen_Click()
Dim intFile As Integer
Dim strFileName As String
Dim var1 As String
Dim var2 As String
intFile = FreeFile
dbDialog.Filter = "Text File (*.txt)|*.txt"
dbDialog.ShowOpen
dbDialog.CancelError = True
On Error GoTo dbErrHandler
strFileName = dbDialog.FileName
Open strFileName For Input As #intFile
Input #intFile, var1
cboHeight.Text = var1
Input #intFile, var2
cboWeight.Text = var2
Close #intFile
dbErrHandler:
Exit Sub
End Sub
The cboHeight and cboWeight are both 2-Dropdown List. And both are dynamic, when a user selects their gender/race in another combo box, it triggers to input a height and weight range list in the 2 combo boxes. So, when you go to select your height, the list looks like:
4' 8"
4' 9"
4' 10"
etc...
The problem is, when this height is saved to the file, the line item added is: "4' 8"""
Then when I try to read it back from the file and put it back into the cboHeight, nothing happens. I cannot figure out why there are 3 quotes at the end of it (I was expecting 2, one for the height, and one for the saved text line).
I need to figure out how to read the height back into the combo box.
Multiple Lines In Saved File
When I save my txt files and load them, I'm having issues saving multiple lines for each text box. I have 5 text boxes and they all save/load correctly except for the fact that they each only save 1 line each.
Last Updated/saved Time For A File
Hi,
I run a macro that opens up and retrieves information from roughly 500 excel files but I also want to obtain the last time each of those files was updated/saved. Can anyone suggest a way I can do this without writing code in each file to be opened?
Thanks in advance,
D
Last File Saved Date Needed
Hi,
I have a macro which opens an excel data file and retrieves data which it then copies to the original excel spreadsheet.
As part of this routine I need to rerieve the date the last time the data file was modified (saved).
I have tried using the following;
Dim dateStamp As String
dateStamp = (ThisWorkbook.BuiltinDocumentProperties("Last Save Time"))
but I get the date and time the file was last accessed accessed, i.e. a few seconds earlier because I have just opened it!
Any guidance or help would be appreciated.
Thanks, Nigel
Finding Recently Saved File
For complicated reasons I wish to find the location of the most recently saved copy of a named file ( eg myfile.exe ) on a user's PC. The user could have saved it anywhere on any drive so a general search would take forever ( anything over a few seconds would be too long to wait ).
Does anybody know if there is API which gives access to a date or alphabetical list of files recently saved?
RTF Tabs To/From Saved File (ASAP)
Please help!!
How can I save and load the "seltabcount" and "seltabs" in an RTF file?
I know how to set them, but are they saved in a file. And if so, how would I load them back to display them on a tabs bar (like MSWord) or in a settings dialog box?
Thanks
Listview AND Colums Saved To A .txt File
hi, I have a listview with 3 colums
first colums contains a name, the second has the time and the third has a time..now...
I have a button that when the user clicks will have whatever line they have selected in the listview saved into a textfile in the "c:" directory....how would i be able to do this? remember, it has to be the one they selected not the whole listview just the one line that is selected...please help!
thx in advanced...
Removing Macros From Saved File
Hello,
I am trying to delete all the macros from a file I create and save with a VBA application. Is there a method to delete macros from a saved file from an active file?
Thanks
Loading An Excel File Saved In VB
The following is how I'm opening an Excel file in Form_Load when VB first starts:
Code:
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open(App.Path & " est.xls")
Set xlSheetData = xlBook.Worksheets("input")
The VB program changes the cell values in test.xls. If the user wants to save the changes, I have a menu option:
Code:
Private Sub mnuSave_Click()
Dim xlFile As String
On Error Resume Next
comDialog.Filter = "Excel File (*.xls) | *.xls"
comDialog.FileName = "*.xls"
xlFile = comDialog.FileName
xlBook.SaveAs xlFile
End Sub
My primary question is - the next time the user runs the VB application, how can I modify the Form_Load code so that the saved "xlFile" is loaded instead of the default "test.xls"? Also, is it possible to show the Excel file name in the caption property of a Form?
Thanks
Reading File Saved As Db Record
I have ASP code that gives the user the option of saving a file as a file, or saving the file to an Access database.
Saving to a db sounds cool, but how do you reconstitute the file from the record in Access?
oh - and how do you put a link in your signature (pot smokin frogs are welcome to answer too)
Opening Saved .msg File In Outlook
I'm developing an Outlook application using VB6.
How do I go about opening a saved .msg file on the hard drive using the Outlook object?
Any code snippet would be appreciated.
Changing Font In A Saved File???
Hey, i'm working on a barcode type program. They need the file saved, but I need to have a barcode generated. Now they are just using a barcode font (the people we send the file too). So I have the font, and the result is in a textbox, with the correct font & size.
The problem I have is how do I save a file with the result saved in that font?
They want to have this program as automated as possible, so don't want to have to open it up ltr to change fonts etc.
I need to be able to print it off in a form etc.(which I will have to get to later. I have no idea how to do that yet. lol)
Is it possible to save the textbox into a file other than simple textfile like notepad?
Is there a way to change the font in the textfile?
Any suggestions would be greatly appreciated.
How Do I Find Out What Type Of A File Was Saved
I an using the below code to Save a file on my system that was saved in a mail message. And then open it up. Problem if it is Excel It gets closed before anybody sees it . I need to know what type it is so I do not close or hide the Excel application . How do I do it???
vntFilename = objExcel.GetSaveAsFilename(Attachments(objItem.ListIndex + 1).FileName)
If vntFilename <> FalseThen
Attachments(objItem.ListIndex + 1).SaveAsFile(vntFilename)
objExcel.Visible = False
objExcel.ScreenUpdating=False
objExcel.Visible = False
Set xlWB = objExcel.Workbooks.Add
objExcel.Visible = False
objExcel.ActiveWorkbook.FollowHyperlink vntFilename,,True
objExcel.Visible = False
set xlWB = nothing
End If
objExcel.Quit 'close excel application
Set objExcel = Nothing
Set objItem = Nothing
Excel Hanging After Opening Saved File
hi
in the following code, i have saved a form to an excel file. But the problem is excel is hanging if tried to open the saved file.
Private Sub cmdsave_Click()
Dim x1app As Excel.Application
Dim x1book As Excel.Workbook
Dim x1sheet As Excel.Worksheet
Dim sPath As String
Dim sfilt As String
Set x1app = CreateObject("excel.application")
Set x1book = x1app.Workbooks.Add
Set x1sheet = x1book.Worksheets(1)
x1sheet.Activate
x1sheet.StandardWidth = 20
x1sheet.Cells(1, 1) = "Name"
x1sheet.Cells(1, 2) = Text1.Text
x1sheet.Cells(2, 1) = "AGE"
x1sheet.Cells(2, 2) = Text2.Text
x1sheet.Cells(3, 1) = "gender"
x1sheet.Cells(3, 2) = Text3.Text
sfilt = "Microsoft Excel File (*.xls),*.xls"
sPath = Application.GetSaveAsFilename("Default.xls", filefilter:=sfilt, Title:="Enter the SaveAs FileName")
ActiveWorkbook.SaveAs FileName:=sPath
End Sub
Is there any way to save the form details to .xls format or .txt format or some other depending upon the users choice, thats is when the save as window pops up the user can be able to select the file format of his save as type and then save it?
i tried to use the getsaveas file name command but it is able to save only to .xls format .
what is a csv file ? is it helpful in this case?
please give me both solutions.
in the above form i also wanted to print the form using :
VB:
Private Sub Command2_Click()
Me.PrintForm
End Sub
if no printer is installed on the system instead of giving a warning message " no printers installed" it is giving a runtime printer error 482
please help.
thank you
|