Wrox Programmer Forums
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2005, 01:43 PM
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Control Options...help!

Hey all...noob to this forum. Hope you all can help with a sticky app issue.
My client wants the ability to edit a Pipe-delimited file in a grid format within a single-form app. I've tried the following...

1)OLE imbedded Excel instance: "floats" from form, resizes awkwardly,
2)Excel Sheet object (non-OLE): can't figure out how to associate with or manipulate external file with object.
3)DataGrid/Connection combo, using either "OLE Jet" or "ODBC Text Engine" connection to flat file as table: Can read and add, but unable to edit or delete. Message along the lines of "updates/deletes not allowed to linked tables with this ISAM"
4)DSO ActiveX Document Framer: perfect, if it would allow opening of non-XLS files in Excel...no dice on that.

...I'm running out of ideas here. What would you recommend using for direct, full-function editing of a pipe-delimited text file in a grid-type control that plays well within a VB6 form and does not involve purchasing extra 3rd-party tools (Standards committee won't support without 6 months of red tape and "evaluation")?

Ken Allhands
Theory and Practice are identical...in theory...
 
Old June 22nd, 2005, 02:01 PM
Registered User
 
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

...almost forgot...also tried Excel Application object...opens up external instance of Excel, and work area must be in-form to meet specs.

thanks in advance for any help...

Ken Allhands
Theory and Practice are identical...in theory...
 
Old August 13th, 2005, 07:27 PM
Authorized User
 
Join Date: Feb 2005
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Ken,

If I understand you correctly, you would like to import data out of a text file, into, for instance Excel.
Here is what I would do.

-Create a new Excel file (I assume using Excel isn't a problem).
-Click on the "record macro" button, and simply do the following: select Data on Toolbar>Import External Data>Import data.
-Select your .txt file and click Open. Follow steps within wizard...
-When done, click on "stop recording macro" button.
-In the VBA screen you should be able to see the code of your macro. Adjust if necessary (VBE opens with Alt+F11).

Here is an example of VBA code created with recording a macro...(NOTE: place the right path and filename in the subroutine here below if using this technique)

Sub Macro1()
Range("A1").Select
With ActiveSheet.QueryTables.Add(Connection:= _
    "TEXT;C:\yourdirectory\yourtextfilename.txt" _
    , Destination:=Range("A1"))
    .Name = "data"
    .FieldNames = True
    .RowNumbers = False
    .FillAdjacentFormulas = False
    .PreserveFormatting = True
    .RefreshOnFileOpen = False
    .RefreshStyle = xlInsertDeleteCells
    .SavePassword = False
    .SaveData = True
    .AdjustColumnWidth = True
    .RefreshPeriod = 0
    .TextFilePromptOnRefresh = False
    .TextFilePlatform = 437
    .TextFileStartRow = 1
    .TextFileParseType = xlDelimited
    .TextFileTextQualifier = xlTextQualifierDoubleQuote
    .TextFileConsecutiveDelimiter = False
    .TextFileTabDelimiter = True
    .TextFileSemicolonDelimiter = False
    .TextFileCommaDelimiter = False
    .TextFileSpaceDelimiter = False
    .TextFileColumnDataTypes = Array(1)
    .TextFileTrailingMinusNumbers = True
    .Refresh BackgroundQuery:=False
End With
End Sub

Hope this helps...





Similar Threads
Thread Thread Starter Forum Replies Last Post
Submit options edove Infopath 1 May 2nd, 2007 09:05 AM
startup options mjuliao Access 4 November 22nd, 2005 04:45 PM
Options Dialog ZiqXx C# 7 July 8th, 2004 06:08 AM
Display Options shadowpug VB.NET 2002/2003 Basics 3 March 10th, 2004 04:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.