Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA 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 January 18th, 2007, 08:01 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anamarijaf
Default Importing text file into excel

Need to do the same thing that does the Data-Import External Data-Edit Text Import, for to import a file that every day has a different extension:
UT4.1
.
.
.
UT4.n
n should be the value taken from a user form.
I make a macro that for e.g. imports the file UT4.133 but when I go to VBA and try to change the extension of the file to "X:\labi\K96_2005\K96\IZVESTAJ\" & [Forms]![UserForm1]![TxtBox1]
it gives a 1004 error.

Sub LABOR()
'Dim GetFileName
' LABOR Macro
' Macro recorded 17.1.2007 by anamarija
'
'
With Selection.QueryTable
.Connection = "TEXT;" & "X:\labi\K96_2005\K96\IZVESTAJ\" & [Forms]![UserForm1]![TxtBox1]
.TextFilePlatform = 1252
.TextFileStartRow = 1
.TextFileParseType = xlFixedWidth
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileColumnDataTypes = Array(1, 1)
.TextFileFixedColumnWidths = Array(1)
.TextFileDecimalSeparator = "."
.TextFileThousandsSeparator = ","
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False
'.Filename = GetFileName()
End With
Sheets("pg 1").Select
ActiveWindow.SmallScroll Down:=42
End Sub

Is there any other simplest way to do this kind of operation?

 
Old January 22nd, 2007, 06:00 AM
Registered User
 
Join Date: Jan 2007
Location: Bangalore, Karnataka, India.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I beleive you are mentioning complete file name in text box and if not you need to do that.
 
Old January 24th, 2007, 05:19 PM
Registered User
 
Join Date: Oct 2005
Location: Oslo, Oslo, Norway.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Just copy and past wil do


 
Old January 27th, 2007, 03:34 AM
Registered User
 
Join Date: Jan 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anamarijaf
Default

Copy and paste of what?

 
Old January 27th, 2007, 05:50 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: , , Finland.
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Anamari,

I think you have no file name in your code

Change this line:
.Connection = "TEXT;" & "X:\labi\K96_2005\K96\IZVESTAJ\" & [Forms]![UserForm1]![TxtBox1]
like this
.Connection = "TEXT;" & "X:\labi\K96_2005\K96\IZVESTAJ\UT4." & [Forms]![UserForm1]![TxtBox1]


-vemaju




Similar Threads
Thread Thread Starter Forum Replies Last Post
importing text file into excel stealthdevil Excel VBA 2 July 10th, 2007 11:28 AM
Importing a text file DBN Beginning VB 6 6 April 24th, 2006 02:52 PM
Importing data from a text file nav PHP How-To 2 March 7th, 2005 02:42 PM
Importing a text file to excel using VB ridders Excel VBA 1 April 10th, 2004 03:01 PM
Problem importing text file manuel Access 3 April 7th, 2004 09:36 AM





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