text import inhibit required

D

danbenfred

As a relative newbie to macros I'd sure appreciate some help. 'I'
generated the macro using the macro recorder facility which recorded my
use of the data/text import wizard. Works great! Only problem is that
as soon as I open the template it immediatly asks me what text file I
want to import. I'd like the template/worksheet to only initiate text
import when I tell it to via a button or shortcut or whatever NOT
immediately on opening. So, firstly I'd be very grateful for the answer
and secondly could anyone recommend a good book that could provide me
with such answers so that I don't have to waste your time on what is
probably a trivial question (for you anyways).
many thx in advance

Danny
 
M

Myrna Larson

I wonder if you somehow placed the code in a module entitled ThisWorkbook,
inside the Workbook_Open event. If so, that's not where it belongs. MOve it to
a Sub in a standard module (you'll have to insert the latter).
 
D

Danny

er...right.....hmmmm. thx for the reply. this is the macro:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 1/10/2005 by Daniel
'

'
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\Daniel\My Documents\test.txt",
Destination:= _
Range("A2"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = xlWindows
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierNone
.TextFileConsecutiveDelimiter = True
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = True
.TextFileColumnDataTypes = Array(1, 1, 1, 1, 1, 1, 1, 1)
.Refresh BackgroundQuery:=False
End With
Application.CommandBars("External Data").Visible = False
End Sub

many thx
Danny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top