+ Reply to Thread
Results 1 to 45 of 45

importing data into a workbook

  1. #1
    Registered User
    Join Date
    08-22-2005
    Posts
    1

    importing data into a workbook

    Greetings

    I am attempting to import a simple text file into a workbook to allow it to apply the information to cells and print.

    Sub load()
    '
    ' load Macro
    '

    Sheets("A").Select
    Range("Q3:Q53").Select
    Selection.ClearContents
    ChDir "C:\messages"
    Workbooks.OpenText FileName:="C:\messages\55C.txt", Origin:=xlWindows _

    Range("A1:A50").Select
    Selection.Copy
    Windows("MURTCM.XLS").Activate
    Range("Q3").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Windows("55C.txt").Activate
    ActiveWindow.Close
    Sheets("Main Menu").Select
    End Sub



    Here is a single cell example of what happens;
    Once the data (mixed alpha and numerical) is copied to the cells, it changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11 (Displayed value)

    I have my separate cells to copy specific data from each line into its own cell.
    this is the formula for cell M7;

    =IF(Q3="","",MID(Q3,10,3))

    The result in cell M7 should be 933 instead its #VALUE!

    I have tried to format the Q3:Q53 cell range to reflect Text and even Custom but it still reverts back.

    Any clues?

    Cheers
    Pb

  2. #2

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  3. #3
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  4. #4

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  5. #5
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  6. #6

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  7. #7
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  8. #8

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  9. #9
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  10. #10
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  11. #11

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  12. #12
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  13. #13

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  14. #14
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  15. #15

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  16. #16
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  17. #17

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  18. #18
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  19. #19

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  20. #20

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  21. #21
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  22. #22

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  23. #23
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  24. #24

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  25. #25
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  26. #26
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  27. #27

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  28. #28

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  29. #29
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  30. #30
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  31. #31

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  32. #32
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  33. #33

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  34. #34

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  35. #35
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  36. #36

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  37. #37
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  38. #38

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  39. #39
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  40. #40

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  41. #41
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  42. #42

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  43. #43
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

  44. #44

    Re: importing data into a workbook

    Hi,

    I had a similar problem. I was working with Delphi to Excel. I
    couldn't get it to work in Delphi. I did get it to work in .NET.

    Here's what I did:

    Excel.Application oXL;
    oXL = new Excel.Application();

    int[,] ColumnFormattingArray = new int[6,2]
    {{1,1},{2,1},{3,1},{4,2},{5,2},{6,2}};
    oXL.Workbooks.OpenText("c:\test.txt", Type.Missing, 1,
    Excel.XlTextParsingType.xlDelimited,
    Excel.XlTextQualifier.xlTextQualifierNone,
    Type.Missing, Type.Missing, Type.Missing, true, Type.Missing,
    Type.Missing, Type.Missing, ColumnFormattingArray, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    oXL.Visible = true;

    I needed column 5 to format as text so it wouldn't do the "2.11604E+11"
    thing. The {5,2} in the array tells column 5 to format as text when it
    dumps to Excel. The {1,1} in the array tells column 1 to format as
    general. I had more than 6 columns in my spreadsheet, but I didn't
    need any formatting done to them, so I didn't have to include them in
    the array. I only had to list up to column 5 since that was the column
    I needed to format.


    PizzaBoy wrote:
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    >
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009



  45. #45
    Dave Peterson
    Guest

    Re: importing data into a workbook

    Actually, the value in that cell didn't change. But the way it was displayed to
    you did.

    211604013993
    and
    2.11604E+11

    have the same underlying value. If you change the format from General to Number
    (0 decimals), you'll see that.

    And when I put 211604013993 in A1 (and saw 2.11604E+11), I got 993 from this
    formula: =MID(A1,10,3)

    But this formula returns text '993. If you're using that result in another
    formula, then I can see where the #value! error comes from--but I don't see it
    just from the formulas you posted.

    If you want to return a number, you could use: =--mid(a1,10,3)






    PizzaBoy wrote:
    >
    > Greetings
    >
    > I am attempting to import a simple text file into a workbook to allow
    > it to apply the information to cells and print.
    >
    > Sub load()
    > '
    > ' load Macro
    > '
    >
    > Sheets("A").Select
    > Range("Q3:Q53").Select
    > Selection.ClearContents
    > ChDir "C:\messages"
    > Workbooks.OpenText FileName:="C:\messages\55C.txt",
    > Origin:=xlWindows _
    >
    > Range("A1:A50").Select
    > Selection.Copy
    > Windows("MURTCM.XLS").Activate
    > Range("Q3").Select
    > ActiveSheet.Paste
    > Application.CutCopyMode = False
    > Windows("55C.txt").Activate
    > ActiveWindow.Close
    > Sheets("Main Menu").Select
    > End Sub
    >
    > Here is a single cell example of what happens;
    > Once the data (mixed alpha and numerical) is copied to the cells, it
    > changes from(Q3 cell value) 211604013993 in the cell to 2.11604E+11
    > (Displayed value)
    >
    > I have my separate cells to copy specific data from each line into its
    > own cell.
    > this is the formula for cell M7;
    >
    > =IF(Q3="","",MID(Q3,10,3))
    >
    > The result in cell M7 should be 933 instead its #VALUE!
    >
    > I have tried to format the Q3:Q53 cell range to reflect Text and even
    > Custom but it still reverts back.
    >
    > Any clues?
    >
    > Cheers
    > Pb
    >
    > --
    > PizzaBoy
    > ------------------------------------------------------------------------
    > PizzaBoy's Profile: http://www.excelforum.com/member.php...o&userid=26536
    > View this thread: http://www.excelforum.com/showthread...hreadid=398009


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1