Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I recorded the below code which opens an ipa file using the Text Import Wizard.

    Code:
    Workbooks.OpenText Filename:= _
    		"C:\Users\Nathan\Documents\Template\orders.ipa", _
    		Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
    		xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
    		, Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo _
    		:=Array(Array(1, 1), Array(2, 2), Array(3, 1), Array(4, 2), Array(5, 1), Array(6, 2), _
    		Array(7, 1), Array(8, 2), Array(9, 1), Array(10, 2), Array(11, 1), Array(12, 2), Array(13, 1 _
    		), Array(14, 2), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 2), Array(19, 1), Array _
    		(20, 2), Array(21, 1), Array(22, 2), Array(23, 1)), TrailingMinusNumbers:=True
    How can I manipulate this to show the file open dialoge, and then automate the text import wizard (as above) with the selected file?

    I know how to manipulate selected excel files using the file open dialogue, but I am struggling with the text import wizard bit.

    TIA

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You can use Application.GetOpenFilename:

    Code:
    Dim varFile As Variant
    ' Display File Open dialog
    varFile = Application.GetOpenFilename("All files (*.*), *.*")
    If VarType(varFile) = vbBoolean Then
      ' User canceled dialog
      Beep
      Exit Sub
    End If
    ' Open selected file
    Workbooks.OpenText Filename:=varFile, _
      Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
      xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
      , Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo _
      :=Array(Array(1, 1), Array(2, 2), Array(3, 1), Array(4, 2), Array(5, 1), Array(6, 2), _
      Array(7, 1), Array(8, 2), Array(9, 1), Array(10, 2), Array(11, 1), Array(12, 2), Array(13, 1 _
      ), Array(14, 2), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 2), Array(19, 1), Array _
      (20, 2), Array(21, 1), Array(22, 2), Array(23, 1)), TrailingMinusNumbers:=True

  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •