Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Open A Csv File With Vbscript And Save To Excel


Does anyone know the correct syntax to open a .csv file in vbscript and then save to an excel file?

All the examples that I've used put all the data from the .csv file into the first column and doesn't seperate them on the delimiter.

Also, does anyone have a good refrence for the properties and method syntax for excel.application?

Thanks in advance!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Open Excel File, Then Save As Another Name
Can anyone help me with this. I ideally want to open a worksheet in excel with a pre-existing template or failing that, just open a file that has been pre-formatted.

After manipulating some data I want to save this file with another name. This way I can keep the original file as a template to be used over again.

How Do I Open Excel File And Save As Csv In VB
I want to open an excel file and then save as csv. Pls how do i using vb 6

Open And Save Excel File From Button
Can anyone tell me how I can go about opening an excel file (C:Documents and SettingsJim DayDesktopAmazonHomeemg-pr~1.xls) and saving it as a tab-delimited text file (C:Documents and SettingsJim DayDesktopAmazonHomeemg-pr~2.txt)? Any help is GREATLY appreciated!

Need Help In Automating File Open And Save In Excel
I have never used VB before. I do use Excel a lot (but simply,) and work developing a database app in Visual FoxPro 8.

I am going to receive some 100 files from a customer to convert from their old .dbf format into VFP. To do this I have already ascertained that I have to open them in Excel as a .dbf, and save them as an Excel file. Then I can import them into VFP. (for some reason they do not retain all their fields if I open them directly in VFP.)

I have made a macro in Excel, using the record option, to open one file and save it where I want it. Here is the code:
Sub Mroe()
'
' Mroe Macro
' Macro to convert dbf files from Mroe
'
' Keyboard Shortcut: Ctrl+Shift+M
'
ChDir "C:MroeOrigData"
Workbooks.Open Filename:="C:MroeOrigData2ES.DBF"
ActiveWorkbook.SaveAs Filename:="C:MroeOrigData2ES.xls", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
End Sub


I don't know how to replace that one file name (2ES.DBF) with a variable so that I can have the macro step through each file in a directory and do this conversion automatically. In VFP, there is a function that reads the files in a directory into an array and I can step through the array. What is the comparable function in VB?

Thanks for any help you can give me!

Demaris

Open Excel File And Save In New Format
Hi all,

I'm sorry for asking such a basic question but i have NO knowledge of how to do this in VB which is a requirement at this time. What i need to do i open an excel file that was saved in Office 95 format and save it in 2000 format. The script will need to accept a root directory and recursively go through each directory seaching for xls file sfrom there. Once it find a file it should open it and then save it in the 2000 format. How can i complete this task?

Any help is appreciated.

Open New Excel File And Save Spreadsheet
Can anyone tell me how to open a new Excel spreadsheet and save it? The Excel file does not exist before this code is run. HELP!

How To Open/save A File At The Open/save Common Dialog Box?
Hi here,

I use the fileopen and filesave common dialog boxes.But I do not know how to really open or save a file in the open/save common dialog box.

Thanks at advance.

Shishydo

About Save File In Vbscript
Hi,all
I'd like to ask you a question about save file in vbscript.

The VBScript is saving a file.
oRs.Save "c:jobs.xml", adPersistXML

The VBSript generates an error message if the file already exists.
How do I change the program so it either save the file (if it does not
exist) or overwrite the file (if it exists).
Is there any option about overwrite in Save?

Thanks

wu7up

VB Excel Help.....? (Open-Append-Save)
Hello everybody,

Am new to this vb excel, I want a sample code to get me started in my vb program in which it:
1. Opens An excel file.
2. Find the last row with blank values and append values on that blank row next to the last row with values.
3. Save. or if it is possible autosave in every 1 minute.

Can anybody please help me on this......

lexthor

Close And Save Excel File, Pass Save Instructions
Hello All,
I was wondering if someone could help me with this. I have the following code-
CODEDim ExcelSheet As Object

Set ExcelSheet = CreateObject("Excel.Application")
ExcelSheet.Application.Visible = True
ExcelSheet.Workbooks.Open ("Z:BDCMDAILYDAILY PACKET COVER PAGE.XLS")
'Now print
ExcelSheet.Range("A1:Q44").Select
ExcelSheet.ActiveSheet.PageSetup.PrintArea = "$A$1:$Q$44"
       
ExcelSheet.ActiveWindow.SelectedSheets.PrintOut copies:=1, collate:=True

ExcelSheet.Application.Quit
Set ExcelSheet = Nothing

End Function

On Word Save Open Excel Document
When a user saves a word document
A macro must run tha opens a specific excel document
The user fills in the nfo then closes the excel document
The word document is saved either befor the excel document is saved or after, it makes no diffrence to me, just so long as the excel document gets completed

thanks in advance

VBscript Qs (force Download Excel File)
I have a link that will obtain data from access and create an excel file to store it in. afterwhich it should display the force download screen to allow the user to save to a location. how to do it?

Vbscript To Extract String From An Excel File
BOnjour,

   Is it possible to extract in a text file the content of
one cell  ( cells E7 for example) of an excel file with vb

Many thanks

Elisabeth

How To Open An Existing Excel File And Add A Record To The End Of The Existing Record And Save It An
How to open an existing excel file and add a record to the end of the existing record and save it and how to delete a row (record) in excel-Urgent-Thanks

Please give me a bit detail the code, that is, copy it and it can be run.

thanks in advance!!!

Simple Way To Open File Resize Image And Save To File
here is the code, i hope it helpfull for you all thx. copy it and paste it in your vb 6 editor.

Sub convertimg(ByVal filesource As String, ByVal filetarget As String, ByVal newwidth As Integer, ByVal newheight As Integer)
  Dim src As PictureBox
  Dim trg As PictureBox
  Set src = Me.Controls.Add("VB.Picturebox", "srcbox")
  Set trg = Me.Controls.Add("VB.Picturebox", "trgbox")
  
  src.AutoSize = True
  src.Width = 1000
  src.Height = 1000
  src.BorderStyle = 0
  src.ScaleHeight = 1000
  src.ScaleWidth = 1000
  src.ScaleMode = 2
  
  trg.Width = newwidth
  trg.Height = newheight
  trg.BorderStyle = 0
  trg.ScaleHeight = newheight
  trg.ScaleWidth = newwidth
  trg.ScaleMode = 2
  
  src.Picture = LoadPicture(filesource)
  trg.Width = newwidth
  trg.Height = newheight
  trg.AutoRedraw = True
  trg.PaintPicture src.Picture, 0, 0, trg.ScaleWidth, trg.ScaleHeight
  Set trg.Picture = trg.Image
  trg.AutoRedraw = False
  SavePicture trg.Image, filetarget

End Sub

www.thepsn.co.nr

-xins

Vbscript, Sql & Write/add Record To Existing Excel File
Hi, Can someone please Assist, as i need this to work it's part of my project!
VBscript, I'm executing a SQL command then with the result data append/add the row to an existing excel file.
Please anyone please Assist!
Scipt: (code)
Dim objXL
Dim File_name
Option WScript
File_name="\srv08-za063source est.xls"
Set objXL = WScript.CreateObject("Excel.Application")
Set wb = objXL.Workbooks.Add
Set ws = objXL.Worksheets(1)
r = 2
objXL.Visible = False

Set objConn = CreateObject( "ADODB.Connection")
Set resultSet = CreateObject ("ADODB.RecordSet")
objConn.Open fcCustom.Value(Process.Company, "ConnectionsFCDB")
strSQL = "select id,ProcessID from dbo.fcEventArchive where EventHistID = 2523"
resultSet.Open strSQL, objConn, 1, 2
On Error Resume Next
resultSet.MoveFirst
Do While Not resultSet.eof
ws.Cells(r, 1).Value = (resultset(0))
ws.Cells(r, 2).Value = (resultset(1))
resultSet.MoveNext
r = r + 1
Loop
resultSet.Close
objConn.Close
Set resultSet = Nothing
Set objConn = Nothing

Vbscript, Sql && Write/add Record To Existing Excel File
Hi, Posted the question before - but could not get it going!

Can someone please Assist, as i need this to work it's part of my project!

VBscript, I'm executing a SQL command then with the result data append/add the row to an existing excel file.
Please anyone please Assist!

Scipt

Code:

Dim objXL
Dim File_name
Option WScript

File_name="\srv08-za063source est.xls"
Set objXL = WScript.CreateObject("Excel.Application")
Set wb = objXL.Workbooks.Add
Set ws = objXL.Worksheets(1)
r = 2
objXL.Visible = False


Set objConn = CreateObject( "ADODB.Connection")
Set resultSet = CreateObject ("ADODB.RecordSet")
objConn.Open fcCustom.Value(Process.Company, "ConnectionsFCDB")
strSQL = "select id,ProcessID from dbo.fcEventArchive where EventHistID = 2523"
resultSet.Open strSQL, objConn, 1, 2

On Error Resume Next
resultSet.MoveFirst

Do While Not resultSet.eof
ws.Cells(r, 1).Value = (resultset(0))
ws.Cells(r, 2).Value = (resultset(1))
resultSet.MoveNext
r = r + 1
Loop

resultSet.Close
objConn.Close
Set resultSet = Nothing
Set objConn = Nothing

Save/Open File
Could someone please help.
I have a program that I'm trying to save the data from one of the forms to the HD. I save the file and it appears in the folder that I saved the file to, but when I load the file the form is still blank. This is my code, could someone tell me where I am missing it.

Private Sub mnuOpen_Click()
'set properties for opening a Data file

Dim FileName As String
Dim E1(27) As String, W1(27) As Integer, G1(27) As Integer, R1(27) As Integer, M1(27) As Integer
CommonDialog1.Filter = "Data Files(*.dat)|*.dat|All Files(*.*)|*.*"
CommonDialog1.FileName = ""
CommonDialog1.ShowOpen
Open CommonDialog1.FileName For Input As #1
For Counter = 0 To 27
Input #1, E1(Counter), W1(Counter), R1(Counter), G1(Counter), M1(Counter)
Next Counter
Close #1
End Sub


Private Sub mnuSave_Click()
'set properties for saving a Data file

CommonDialog1.Filter = "Data Files(*.dat)|*.dat|All Files(*.*)|*.*"
Call mnuSaveAs_Click

End Sub


Private Sub mnuSaveAs_Click()
'set properties for saving a Data file
Dim FileName As String
Dim E1(27) As String, W1(27) As Integer, G1(27) As Integer, R1(27) As Integer, M1(27) As Integer
CommonDialog1.Filter = "Data Files(*.dat)|*.dat|All Files(*.*)|*.*"
CommonDialog1.FileName = BodyPartCombo
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Output As #1
For Counter = 0 To 27
Write #1, E1(Counter), W1(Counter), R1(Counter), G1(Counter), M1(Counter)
Next Counter
Close #1

End Sub

Open Then Save To File
Hey, How do I save what is in text1 to a file without overwriting the file? I'm trying to make a big log of what happens on my server. Thanks, Nick

Open/Save File
Does someone know a function that will create the famous popup 'Open a file' dialog box? I need this so the user can specify browse their system to open a file or save a file for that matter. I'm sure this is probably just an API call or something.

Thanks in advance for your help!

Can't Open Save File
<html><div style='background-color:'><DIV>
<DIV>
<DIV></DIV>
<DIV></DIV>
<DIV>I'm having problems with saving and opening mulitple line files.  I can save the multiple lines boxes  to a file but retreaving them and having them appear is another story.  They all want to appear in the same line and that where I get my error. Please if you can help me.</DIV></DIV>
<P><BR clear=all> </P></DIV></div><br clear=all><hr>Join the world’s largest e-mail service with MSN Hotmail. <a href='http://g.msn.com/1HM301601/44'>Click Here</a><br></html>

Open Multiple Weblinks - Save In Excel - Exctract Info From Specific Cells, Etc
Your help is much appreciated.

Here is a description:

There is a website:
http://www.advocis.ca/faa_resultspc...1&maxvalue=1723

I would like to extract the contact info and create an excel file.

One way is to do this manully (click on each link - copy info - paste to excel). This is very time consuming if you have 10,000 records.


The other way is to extract the weblinks of all these records:

For example:

http://www.advocis.ca/faa_disp_prof...88&pc=T6E%205J3

http://www.advocis.ca/faa_disp_prof...54&pc=T6E%205Z9

etc, etc.



My question is how to write a macro that first opens a weblink, then extracts info from appropriate cells, then copies this info into a new excel sheet, then closes this weblink and then open another link to repeat the process (so I will not run out of memeory).


Can someone help?

Thanks a million.

Need Help With Open/save File Dialog Box
I'm creating a vbScript macro in Microsoft word, and I need to open up a dialog box that will let the user select a file - all I need from this interaction is the file name.

Does anybody know if there is some kind of simple "InputBox" like command to do this? I know there is in regular Visual Basic, but how about for macros?Must I create my own file dialog box from scratch using Dir()? That would suck.

VBA Open Paint And Save File
Hi,

Using Access, i need to open a template image in paint, and automatically save it with a different file name (each time code is run)

my code so far is
stAppName = "C:WINDOWSsystem32mspaint.exe"
stfilename = "c:ody.jpg"
'Call Shell(stAppName & " " & stfilename, 1)

which opens the image in paint, anyone know how to automatically save it as something else?

thanks

Using VB To Save An Open Notepad File
Hi,

I was hoping someone might be able to help me with a quick question. I don't have any written code, sorry.

I used the macro recorder to try and save an open notepad file on my desktop but no code appeared in the vb module. Can this be done? I'm a little lost for ideas.
Any help would be greatly appreciated.

Thanks.

Macro Help: Open, Save, To Txt File
Hi

I'm a first time poster here, it's a great forum for newbees like me here although most of it just flies over my head... any way here is my problem.

I have recorded the following macro, it copies and paste special value the "upload" worksheet and then deletes the rest of the tab and saves the file as a text file.

Now how do I instruct in VB to open all the files in this directory and do the same.

Thanks in advance.

Code:
Sheets("Upload").Select
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets(Array("Instruct", "Cost Center", "CF004 ", "Smoothing", "Cnslt Bud", "Load06" _
, "Load07", "Feed", "Assume")).Select
Sheets("Instruct").Activate

Sheets(Array("Instruct", "Cost Center", "CF004 ", "Smoothing", "Cnslt Bud", "Load06" _
, "Load07", "Feed", "Assume", "FY06", "FY07", "SumByAcct", "SumP&L", "Upload 06")). _
Select
Application.CutCopyMode = False
ActiveWindow.SelectedSheets.Delete
ChDir _
"S:AcctgCGITBudgetFY 2007Cost Center BudgetsUploadTestUploadTestUpload1"
ActiveWorkbook.SaveAs Filename:= _
"S:AcctgCGITBudgetFY 2007Cost Center BudgetsUploadTestUploadTestUpload17705.txt" _
, FileFormat:=xlText, CreateBackup:=False

ActiveWorkbook.Save
ActiveWorkbook.Close
Edit by italkid: The use of [vb]][ and [/vb] tags makes your code better readable...

Open && Save File(s) Issue.
Edit by italkid: Split off from THIS thread
Okej, my mistake. I first added ".xls" to the 'default' filename. But that's no use so I don't have to do that. Now I only have to add ".xls" behind the filename.

I also got another question / problem.

Here's what I want:

1. Open an Excel file named "1" invisible
|
v
2. Edit the Excel file "1"
|
v
3. Save the Excel file with another name ("2")
|
v
4. Open the new saved excel file "2" visible, "1" needs to stay invisible.

I've made the next code to realise that.
1:

Code:
Dim XL As Object
Set XL = CreateObject("excel.application")
Set XL = GetObject(, "excel.application")
XL.visible = false
XL.workbooks.open ("c:1.xls")
2:

Code:
'editing the excel file
3:

Code:
XL.workbooks("1.xls").SaveCopyAs ("c:2.xls")
4:

Code:
XL.workbooks.open ("2.xls")
XL.workbooks("1.xls").visible = false
XL.workbooks("2.xls").visible = true

Unfortunately this doesn't work (else I wouldn't ask the question). Anyone an idea of how i can realise this.

Save List To File, Re-open...
1) Create a list of Graphics file names...
2) Save the list to file...
3) Re-open the list to open the Graphics files...

I can't do it..! I've been trying for weeks.. The nearest thing to it would be a WinAmp Playlist.. what could be easier?
Anyone tell me in 25 words or less? lol

Save Unsaved File Before Open Or New?
HI,

Im using Common Dialog.
I can do save, open and new, but there is something else i should
do, and i dont know how: If the user work with the program and then try to open or create a new file it should Msgbox that the info has changed and ask the user if he wants to save it, but it should just happend when something in the form change after last Save, How can I know when this happends? I think i could compare the info on the form with the info in the file, but isnt there any other way to do it?

Thanks
JCI

Save && Open A File (RESOLVED)
Could someone help me ? First off how do i code 3 optButton responce to see which one was selected ( optYes ; optNo ; optMayBe ) then save the answer ?

This is what i have sofar! I don't know how to get the answers back on the form in the right spot.

Also how do i make sure when i save/open that the For/Next counters start the same ?


VB Code:
Private Sub cmdSave_Click()                Dim fs As New FileSystemObject        Dim ts As TextStream        Dim blankFolder As Boolean        Dim stFolder As String        Dim SSNum As String        Dim txtObject As Control        Dim bState As Boolean        'Consintrate strings        SSNum = txtSSNum1.Text & "-" & txtSSNum2.Text & "-" & txtSSNum3.Text        stFolder = "C:My Documents" & SSNum    '***********************************************    'Check to see if file name was entered    '***********************************************        If txtYourName.Text = "" Then MsgBox "You forgot the Name"        txtYourName.SetFocus        If txtYourName.Text = "" Then Exit Sub   '************************************************   'Check to see if folder ID was entered   '************************************************        If Len(SSNum) <= 10 Then _        MsgBox "You forgot your Social Security Number"        txtSSNum1.SetFocus        If Len(SSNum) <= 10 Then Exit Sub   '************************************************    'Check to see if folder exist   '************************************************        blankFolder = fs.FolderExists(stFolder)        If blankFolder = True Then MsgBox "Folder Exist"        If blankFolder = True Then txtYourName.SetFocus        If blankFolder = True Then Exit Sub   '************************************************      'Check That all txtBox's are filled in   '************************************************        bState = True        For Each txtObject In Me.Controls            If TypeOf txtObject Is TextBox Then                If txtObject.Text = "" Then bState = False                txtObject.SetFocus                Else                End If        Next            If bState = False Then MsgBox "You forgot to fill in an answer"            If bState = False Then Exit Sub    '************************************************       '   Make the folder and name it    '************************************************        MkDir ("c:/My Documents/" & SSNum)            MsgBox "Created the folder" & SSNum   '************************************************   '    Create the file name and put something in it   '************************************************        Set ts = fs.CreateTextFile("C:/My Documents/" & SSNum & "/" & txtYourName.Text & ".txt")            MsgBox "Created the file " & txtYourName.Text   '************************************************    '    Write to file 22 responces   '    Write the texBoxes to File      '************************************************        For Each txtObject In Me.Controls            If TypeOf txtObject Is TextBox Then                ts.WriteLine (txtObject.Text)            End If   '************************************************   '    THE FIRST THREE BUTTON OPT.   '************************************************                       '    optInPerson ; optOverThePhone ; optJobShow   '************************************************   'How do you "If" three to see which one is set?   '   '   '************************************************   '            THE FIRST TWO BUTTON OPT/   '************************************************   '    optAdYes ; optAdNo   '************************************************        If optAdYes.Value = True Then        ts.WriteLine "True"    Else        ts.WriteLine"False"    End If   '************************************************   '    THE SECOUND TWO BUTTON OPT.   '************************************************   '    optBenefitsYes ; optBenefitsNo   '************************************************    If optBenefitsYes.Value = True Then        ts.WriteLine "True"    Else        ts.WriteLine"False"    End If   '************************************************   '    THE SECOUND THREE BUTTON OPT.   '************************************************   'How do you "If" three to see which one is set?   '   '   '************************************************   '    Tell you wrote to the file   '************************************************            MsgBox "Wrote to file " & txtYourName.Text        ts.Close       End Sub'---------------------------------------------------------------------------------------------Private Sub cmdOpen_Click()            Dim fs As New FileSystemObject        Dim ts As TextStream        Dim blankFolder As Boolean        Dim blankFile As Boolean        Dim SSNum As String        Dim txtObject As Control        Dim stFolder As String        Dim StFile As String   '**************************************************       '    Consentrate strings   '**************************************************             SSNum = txtSSNum1.Text & "-" & txtSSNum2.Text & "-" & txtSSNum3.Text        stFolder = "c:My Documents" & SSNum        StFile = stFolder & "" & txtYourName.Text & ".txt"   '*************************************************    'Check to see if file name was entered   '*************************************************        If txtYourName.Text = "" Then MsgBox "You forgot the Name"        txtYourName.SetFocus        If txtYourName.Text = "" Then Exit Sub   '*************************************************        'Check to see if folder ID was entered   '*************************************************        If Len(SSNum) <= 10 Then MsgBox "You forgot your Social Security Number"        txtSSNum1.SetFocus        If Len(SSNum) <= 10 Then Exit Sub   '*************************************************   'Check to see if Folder Exist   '*************************************************        blankFolder = fs.FolderExists(stFolder)        If blankFolder = False Then MsgBox "Folder does not Exist"        'Clear the txtBoxes        If blankFolder = False Then txtYourName.Text = ""        If blankFolder = False Then txtSSNum1.Text = ""        If blankFolder = False Then txtSSNum2.Text = ""        If blankFolder = False Then txtSSNum3.Text = ""        'Reset focus        If blankFolder = False Then txtYourName.SetFocus        'Exit the Sub        If blankFolder = False Then Exit Sub   '*************************************************    'Check to see if File Exist   '*************************************************        blankFile = fs.FileExists(StFile)        If blankFile = False Then MsgBox "File does not Exist"        'Clear the txtBoxes        If blankFile = False Then txtYourName.Text = ""        If blankFile = False Then txtSSNum1.Text = ""        If blankFile = False Then txtSSNum2.Text = ""        If blankFile = False Then txtSSNum3.Text = ""        'Reset focus        If blankFile = False Then txtYourName.SetFocus        'Exit the Sub        If blankFile = False Then Exit Sub   '***************************************************    'Open the file and get the contents   '***************************************************        Set ts = fs.OpenTextFile("C:My Documents" & SSNum & "" & txtYourName.Text & ".Txt")                For Each txtObject In Me.Controls            If TypeOf txtObject Is TextBox Then                ts.ReadLine (txtObject.Text)            End If        Next  '*************************************************  ' NOW TO GET OPT RESPONCES   *************************************************   '    THE FIRST THREE BUTTON OPT.   '************************************************                       '    optInPerson ; optOverThePhone ; optJobShow   '************************************************   'How do you "If" three to see which one is set?   '   '   '************************************************   '            THE FIRST TWO BUTTON OPT/   '************************************************   '    optAdYes ; optAdNo   '************************************************       '   '   '   '************************************************   '    THE SECOUND TWO BUTTON OPT.   '************************************************   '    optBenefitsYes ; optBenefitsNo   '************************************************   '   '   '   '************************************************   '    THE SECOUND THREE BUTTON OPT.   '************************************************   'How do you "If" three to see which one is set?   '   '   '************************************************              '    Let them know you opened the file   '************************************************            MsgBox " Opened file " & txtYourName.Text        ts.Close       End Sub

Open Text File, Save
how can I do this? I want to make a batch replace program.

File Open/save Trick.....
Hiyas,

I have a bit of a dilema.

I was downloading a 35 meg file, and got 15 megs in, and the power went off. When I turned the PC back on and starting resuming, I realised that there was a chance that the 15 megs could've been corrupted, but I'd never had a problem like that before (even time I've reset my PC I've been able to resume no problem)... I finish the download, and it's corrupted.

Now, I've redownloaded about 22 megs. I just had an idea that I could perhaps fix the partly corrupted file and save me a few hours downloading on a 33.6k modem.

I was thinking I could open the corruped file (35 meg) for writing, and open the partly downloaded file (22 meg) for read. I then put the first 22 megs into a variable and dump it over into place on the 35 meg file, which SHOULD, in theory, overwrite the corrupted parts of the file.

I just want to try this... But it's not working. I used the code below.


Code:
Dim File

Open App.Path & "FileTest1" For Binary Access Write As #1
Open App.Path & "FileTest2" For Binary Access Read As #2

ReDim File(1 To LOF(2))

Get #2, , File
Put #1, , File

Close #2
Close #1


But when it gets to ReDim it runs out of memory. How can I get around this?

Thanks!

-Git

Open Or Save Attached File, HELP!!!!!!!
Please help me!!!
How can I save to an specific directory a file attached to an e-mail, or how can I open it.
Thanks

Can I Use The File Open/save Dialog With API
I am trying to keep an application's size down to the absolute minimum. I can use the CommonDialog control if I have to , but I would prefer to use an API call to show the file open and save dialogs.

I'm sure its simple, I just haven't found the codes yet. Please help

Open Excel And Make It Open A Text File
Hey, friends,

I need to open excel, make it open a comma delimited text file, format it, and after that, end my application leaving the user in excel... i am starting as follows but at that point, excel does not appear, why? (it seems to work but i can not see excel)

Quote:





Dim XlApp As Excel.Application
Set XlApp = New Excel.Application
XlApp.DisplayFullScreen = True






Thanks for your help!

Heyner

File Open && File Save Questions
Again drawing on the groups experience:-

1. For general file opening and file saving, using VB6, are there any issues
with using the FileOpen and FileSave Common Dialog Boxes?

2. Is using the FileOpen and FileSave Common Dialog Boxes the best way to go
in general?

3. For Most of my projects I will be using the same types of data input form
and report output form, as discussed here recently. Also, the files that are
saved or recalled are all of the same type (text files with extension .job)
and are, ideally for me, saved in the same directory (App.Path / job). This
being the case the FileOpen and FileSave Common Dialog Boxes seem to be a
bit of an over kill?

a) When file saving; only the "file name", without extension is needed. This
could be supplied more simply on the data input form as the first part of
the required data, or is this too crude?

b) When recalling an existing job I could get away with just the FileListBox
because I know (or think I know) where the Drive/Directory is. Or is this
also too crude.

a) and b) appear very simple to me but don't mimic your conventional Windows
style application. I would therefore be most grateful for your advice.


Regards

Martin Double

Email: Join Bytes!
Web Site: http://home.btconnect.com/cadoss

Open File, Add Characters, Save File
Is it possible to open any file, append a few characters (e.g. asdf) to the begining of the file, and then save it again? I know the file would then be corrupt, but could I then just open the file again in VB, delete the appended characters (asdf) and make the file normal and readable again???

What Is The Best Way To Save Data As Excel File If I Don't Know User's Excel Version?
do i want to query their version of excel then load
corresponding libraries...

thank you

How To Center A File Save/open Dialog Box?
Hi,
I am saving / opening files using the API VBGetSaveFileName with a command like this:


Code:
VBGetSaveFileName(flName, , , "Text Files (*.TXT)|*.TXT|All Files (*.*)|*.*", 1, , , "TXT", frmMain.hwnd) Then
....
Is there any options that can be passed into this function that will enable me to center the resulting save dialog box on my frmMain or indeed in the center of the screen, rather than 0,0.???

Cheers
Pete

Open, Edit, Save && Reload File - Help Please!
I have spent some time looking into whats best to do my project in & I think VB6 is.

I am trying to open a file & edit it, save it & re-load it back into a process. I have also thought that maybe replacing the file with an already edited version, then re-load that into the process.

I have only figured out a small base code, but I really need help on everything.

Code:
dim known as long
Call readalong("process, &HADDRESS, known)
if known = 0 then
'edit the file (#Replace the file)
'save the file (#Would not need this step)
'load file into process
End if


I need to load the file at the correct time, so when 'known = 0' the code would run.

May some one please help me please.
Trix

[EDIT] With the code below I Can simply overwrite the content of the original file with what I type into the textbox!
Thnx: |2eM!x

Code:
Dim strBuff As String
ff = FreeFile
Open App.Path & "/FILE" For Output Lock Read As #ff 'open FILE
Print #ff, Text1.Text
Print #ff, Text2.Text
Print #ff, Text3.Text
Print #ff, Text4.Text
Print #ff, Text5.Text
Print #ff, Text6.Text
Print #ff, Text7.Text
Close #ff


Now I have changed the file, I need to load it into a process, how do I do that?

How To Open A Fax File Then To Save It As An .tiff Image
Thanks. I searched all forums but did not see any alike topics.

TXT File Open, Modify, Save As New (RESOLVED)
got this to start off


Code:
Private Sub mnuConvert_Click()

Call mnuCloseLog_Click 'Close Log file first

Open Temp For Input As #1 'Open log file

Open NewLogFile For Append As #2

Close #2

Close #1

End Sub


want to open a log file, stored in (Temp) delete the  then save to another file (NewLogFile), whats the best way to do this, please use code i already have and decare any variables

thanks in advance

ATTENTION... Kleinma (file Save-open)
kleinma,

I seen in one of your posts that you have eVB 3.0

I was wondering if you have any code example on how I can open and save a sequential text file.

In VB6 I use ...

TO SAVE:
Open App.Path & "filename.txt" For Output As FileNum
Print #FileNum, TxtDate.Text
Print #FileNum, "bla bla bla"
Print #FileNum, "bla bla bla"
Print #FileNum, "bla bla bla"
Close #FileNum

TO OPEN:
Open "filename.txt" For Input As FileNum
Line Input #FileNum, TmpStr
TxtDate.Text = TmpStr
Do Until EOF(1)
Line Input #FileNum, TmpStr
List1.AddItem TmpStr
Loop
Close #FileNum

How do I do this in eVB?

Thanks

How To Open/save Text File? [RESOLVED!]
God, its a bad day for me today - i feel stupid asking, but how do you open/save a text file? I forgot

Components Involved In File Open And Save
Dear Sir/ Madam,

I am Saila, a freelancer working for Free Software Wing : The software produced by this wing is OPEN (and it may also be available to everybody free of COST).

Please visit
www.iiit.net and
http://www.iiit.net/research/ltrc/ltrchome.htm

We are currently creating an application which will enable all the users of Indian Languages to use any word processors in their respective languages without requiring to download the necessary fonts each time.

The company where I am working has developed ISCII (indian standard code for information interchange) similar to ASCII, which caters to all Indian languages

We know how to handle ISCII part. We also have several
ISCII to glyph bidirectional converters.

As far as "document" structure is concerned one can also
standardise on say HTML format which can be handled by most word processors.

So a user can work with Indian languages using above tools. But he has to give several "commands" in the process. What we wanted to was to make the whole process user transparent by using appropriate "component model" if possible.

So, if we know how the file open and save works or what are the components involved during file open and file save, it will be possible for us to create a common component which will enable the user to directly go to the document part without having to go through lengthy process.

Please help.

Open And Save File Dialog Question...
Is there a standard or Default Save or Open Dialog Box that I can call through the code or do I have to make my own? (i.e. A typing program, Type your text, select file - save, brings up what looks to be a form where you can select your HD and folders to save it in.) Thanks

Help!!Open/save File With Common Dialog
Hi here,
I want to use a common dialog to open and save file. But as you know : the Open and Save As dialog boxes don't actually perform any function; they simply get the information from users. It's up to our application code to perform the necessary commands to complete the task .

And now I do not know how to do that.

Thanks in advance.
Shishydo

Can't Get Rid Of Save File Prompt In Excel With XP Version Of Excel
Hiyas..

At work, I am working on an application to write thousands of records from Access to Excel. Works fine, probably because I'm using a different version of Excel, most likely 2000.. Can't recall offhand for sure.

At home, the same code generates a dialogue box to save the Excel spreadsheet. I have a different version of Excel, I'm assuming it's XP, I can't find out any version info on it.

The code snippet in question is:


Code:
MyXLApp.DisplayAlerts = False 'subdue any Excel specific msg boxes
MyXLApp.Workbooks(1).SaveAs FileName:=PathName 'Save the Excel file
MyXLApp.Quit 'Quit the Excel application
Set MyXLApp = Nothing 'Clear object
At work, this works great.

At home, I get the Save As dialogue box, which won't go away. If I hit cancel, the app crashes. It also says the file is already open, and do I want to Switch to it. That doesn't help, either.

Also, I tried the trick of inserting an if/then statement in the above code to check to see if dir(pathname) existed, and if so, delete it. It wouldn't delete, as it was still open.

So... If anyone knows how to make the above code work in ALL versions of Excel, that'd be great.

Thanks much!
Bill Boxall

Array (doesn't Add/edit/open/save To .txt File) How To?
I have established my array and the navigation buttons next and prev work. Main problem is that it won't add/edit/open/save to a .txt file) using the Common Dialog control. Here is my code......

Private Type Fault

regnumber As String * 10
username As String * 10
date As Date
campus As String * 15
roomnumber As String * 4
pcnumber As String * 4
description As String * 100

End Type

Dim FaultArray(0 To 100) As Fault
Dim AllFaults As Integer
Dim ThisFault As Integer
Dim FaultLength As Fault
Dim MaxRecord As Integer

Public Sub EnterFaultArray()

FaultArray(1).regnumber = "1"
FaultArray(1).username = "James"
FaultArray(1).date = "01/11/03"
FaultArray(1).campus = "Preston"
FaultArray(1).roomnumber = "311"
FaultArray(1).pcnumber = "43"
FaultArray(1).description = "Mouse not functioning"





FaultArray(2).regnumber = "2"
FaultArray(2).username = "Tania"
FaultArray(2).date = "04/11/03"
FaultArray(2).campus = "Brodmeadows"
FaultArray(2).roomnumber = "123"
FaultArray(2).pcnumber = "5"
FaultArray(2).description = "Computer crashes on start up"





FaultArray(3).regnumber = "3"
FaultArray(3).username = "David"
FaultArray(3).date = "05/11/03"
FaultArray(3).campus = "Preston"
FaultArray(3).roomnumber = "205"
FaultArray(3).pcnumber = "5"
FaultArray(3).description = "No sound coming out of speakers"





FaultArray(4).regnumber = "4"
FaultArray(4).username = "Peter"
FaultArray(4).date = "07/11/03"
FaultArray(4).campus = "Preston"
FaultArray(4).roomnumber = "253"
FaultArray(4).pcnumber = "24"
FaultArray(4).description = "Monitor showing funny colors"





FaultArray(5).regnumber = "5"
FaultArray(5).username = "Patricia"
FaultArray(5).date = "10/11/03"
FaultArray(5).campus = "Epping"
FaultArray(5).roomnumber = "112"
FaultArray(5).pcnumber = "1"
FaultArray(5).description = "Not connecting to Internet"





FaultArray(6).regnumber = "6"
FaultArray(6).username = "Tamara"
FaultArray(6).date = "13/11/03"
FaultArray(6).campus = "Epping"
FaultArray(6).roomnumber = "221"
FaultArray(6).pcnumber = "19"
FaultArray(6).description = "Keyboard faulty"





FaultArray(7).regnumber = "7"
FaultArray(7).username = "Dennis"
FaultArray(7).date = "13/11/03"
FaultArray(7).campus = "Greensborough"
FaultArray(7).roomnumber = "323"
FaultArray(7).pcnumber = "5"
FaultArray(7).description = "Not Printing, not connected to network"





FaultArray(8).regnumber = "8"
FaultArray(8).username = "Jessica"
FaultArray(8).date = "15/11/03"
FaultArray(8).campus = "Epping"
FaultArray(8).roomnumber = "32"
FaultArray(8).pcnumber = "15"
FaultArray(8).description = "Disk stuck in floppy disk drive"





FaultArray(9).regnumber = "9"
FaultArray(9).username = "Nick"
FaultArray(9).date = "19/11/03"
FaultArray(9).campus = "Preston"
FaultArray(9).roomnumber = "342"
FaultArray(9).pcnumber = "28"
FaultArray(9).description = "Wont open word application"





FaultArray(10).regnumber = "10"
FaultArray(10).username = "John"
FaultArray(10).date = "21/11/03"
FaultArray(10).campus = "Greensborough"
FaultArray(10).roomnumber = "211"
FaultArray(10).pcnumber = "3"
FaultArray(10).description = "Jammed CD rom drive"

End Sub

Private Sub ArrayShow(index As Integer)

txtregnumber = FaultArray(index).regnumber
txtusername = FaultArray(index).username
txtdate = FaultArray(index).date
txtcampus = FaultArray(index).campus
txtroomnumber = FaultArray(index).roomnumber
txtpcnumber = FaultArray(index).pcnumber
txtdescription = FaultArray(index).description

End Sub
Private Sub cmdexit_Click()
End
End Sub

Private Sub cmdclear_Click()
txtregnumber.Text = " "
txtusername.Text = " "
txtdate.Text = " "
txtcampus.Text = " "
txtroomnumber.Text = " "
txtpcnumber.Text = " "
txtdescription.Text = " "
End Sub

Private Sub cmdfirst_Click()

cmdfirst.Enabled = False

End Sub

Private Sub cmdlast_Click()

cmdlast.Enabled = False


End Sub

Private Sub cmdnext_Click()

If ThisFault = MaxRecord - 1 Then
cmdnext.Enabled = False
Else
cmdnext.Enabled = True

End If

ThisFault = ThisFault + 1
ArrayShow (ThisFault)

cmdprevious.Enabled = True

If Val(ThisFault) = Val(AllFaults) Then
cmdnext.Enabled = False
End If
End Sub

Private Sub cmdprevious_Click()
If ThisFault = 1 Then
cmdprevious.Enabled = False
End If
ThisFault = ThisFault - 1
ArrayShow (ThisFault)

End Sub

Private Sub Form_Load()

Call EnterFaultArray
Call ArrayShow(1)
ThisFault = 1
cmdprevious.Enabled = False


End Sub

Private Sub cmdopen_Click()
Dim openfile As String, Item As String
Dim i As Integer
CommonDialog1.CancelError = True
On Error GoTo CancelButton
CommonDialog1.Filter = "Text files (*.txt)|*.txt"
CommonDialog1.ShowOpen
openfile = CommonDialog1.FileTitle
Open openfile For Input As #1
i = 0
Sum = 0
Do Until EOF(1)
Input #1, FaultArray
Sum = Sum + FaultArray
Loop
Close #1
i = i + 1
n = i

Close #1
CancelButton:

Exit Sub


End Sub

Private Sub cmdsave_Click()
Dim NewFile As String
Dim Fault As Fault, ThisFault As Integer

CommonDialog1.CancelError = True
On Error GoTo CancelButton
CommonDialog1.Filter = "Text File (*.txt)|*.txt*"
CommonDialog1.ShowSave
NewFile = CommonDialog1.FileName
Open NewFile For Random As #1 Len = Len(FaultArray(1))
Put #1, ThisFault, FaultArray(ThisFault)
ThisFault = 1

CancelButton:
Exit Sub
End Sub


I have an cmdadd,cmd,modify,cmdopen,cmdsave that are all not working. Can anyone help??

Copyright © 2005-08 www.BigResource.com, All rights reserved