+ Reply to Thread
Results 1 to 11 of 11

Workbook.Open Filename procedure

  1. #1
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Workbook.Open Filename procedure

    I am trying to modify my macro for the import of XML files. I want the new macro to open CSV files. I attempted it but encountered a problem with the syntax for the Open Filename procedure.

    Just below is the code with the problem. Further down is the whole script.
    Please somebody assist in debugging this problem.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Last edited by dschmitt; 06-16-2010 at 10:30 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    found the problem.

    Please Login or Register  to view this content.

  3. #3
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    I have another problem with the Workbooks.Open Filename procedure.

    The script line below opens the comma delimited CSV file in a new workbook. That means if I execute the macro in one workbook the data will appear in a newly created workbook.

    That's bad. I need the data in the workbook in which I execute the macro. Is there a way to modify the script below so that I can achieve that?

    I tried ActiveWorkbook and ActiveWorksheet but both don't work.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    03-11-2010
    Location
    India
    MS-Off Ver
    2010
    Posts
    268

    Re: Problem with Workbook.Open Filename procedure

    One work-around can be to copy data from new workbook, paste in your workbook (ehich has macro), and close the new workbook.

    hth
    Ajay

  5. #5
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    yes, that one I already thought about. The other one is to import the data. I am working on that too. But with that I am having a problem. I may have to ask a question about that tomorrow.

    Anyway, I hope that there is a more elegant way than to copy the data and delete the workbook.

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Problem with Workbook.Open Filename procedure

    You either copy or you import; no other choices since if you open a workbook, you obviously get a new workbook opened!
    Remember what the dormouse said
    Feed your head

  7. #7
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    I was afraid I would receive this sobering answer abruptly pulling me out of my dream
    Thanks.

  8. #8
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Problem with Workbook.Open Filename procedure

    That may be the first time I've ever been accused of sobering things up...

  9. #9
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    I decided to go with the open file method.

    The below macro does copy the data from the opened csv file to my main workbook. However, closing the csv workbook gives me a "script out of range error".
    Please somebody help to debug this step. Also please include a handler that deals with the keep/not keep info in the clipboard at closing.

    Below is the line that gives me the error. Furtherdown is the complete sub. Attached is a test.csv file.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by dschmitt; 06-16-2010 at 10:01 PM.

  10. #10
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    I solved the problem that I had with closing the csv workbook. See script below.
    But I am still looking for code to handle the question about what to do with the large data in the clipboard.

    Please Login or Register  to view this content.

  11. #11
    Valued Forum Contributor
    Join Date
    02-21-2010
    Location
    Tokyo, Japan
    MS-Off Ver
    Excel 2007
    Posts
    502

    Re: Problem with Workbook.Open Filename procedure

    solved it.

    Please Login or Register  to view this content.

+ 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