Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi All
I'm trying to create a form where you can generate a series of text files that come from a spreadsheet. The spreadsheet has 7 columns and each text file should have 7 entries in it (a single record/row). The spreadsheet looks like: Name Value 1 Value 2 Value 3 Value 4 Value 5 Value 6 With the code I have I want the text files to have the format: Value 1 Value 2 Value 3 Value 4 Value 5 Value 6 The file will have the text from the name column as its filename. However instead of the extension .txt for a text file I would like to have the extensions .jgw and .jpw and .tfw. The following code is Private Sub cmdRange_Click() Set myRng = Nothing On Error Resume Next Set myRng = Application.InputBox(prompt:="Select a range with the mouse", _ Type:=8) On Error GoTo 0 If myRng Is Nothing Then 'use hit cancel Exit Sub End If End Sub Sub cmdGenerate_Click() 'Select worldfile type from option buttons Select Case True Case optJpeg.Value Extension = ".jgw" MsgBox "You've selected Jpegs" Case optIllustrator.Value Extension = ".jpw" MsgBox "You've selected Illustrator files" Case optTif.Value Extension = ".tfw" MsgBox "You've selected Tif files" End Select 'Macro for creating world files ChDir "C:\working_data" For Each myRng In Range (myRng) If myRng.Value < "" Then FNum = FreeFile Open myRng.Value & "Extension" For Output Access Write As #FNum Print #FNum, myRng(1, 2).Value Print #FNum, myRng(1, 3).Value Print #FNum, myRng(1, 4).Value Print #FNum, myRng(1, 5).Value Print #FNum, myRng(1, 6).Value Print #FNum, myRng(1, 7).Value Close #FNum End If Next myRng End Sub The code seem okay for the most part but breaks down at For Each myRng In Range (myRng) If anybody has ideas out there it would be greatly appreciated. Thanks, Mike |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Help importing text files into individual cells | Excel Discussion (Misc queries) | |||
Importing text files with mathematical characters | Excel Discussion (Misc queries) | |||
Prompted to convert the file's text encoding... | Excel Discussion (Misc queries) | |||
Replacing text in Excel files on disk? | Excel Discussion (Misc queries) | |||
Read Text File into Excel Using VBA | Excel Discussion (Misc queries) |