Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    FilePicker / Memory (Word 2002)

    I'm performing a merge with VBA. The active document is the merge document, and the user will select the data file, also a Word document. I've been using msoFileDialogFilePicker, and I've run into a problem: on the second or third attempt, a message displays saying "There is not enough memory or disk space to perform this operation." I don't have a problem with this code if I specify the file; I encournter this difficulty only when I use the FilePicker.

    I'm using a Dell Precision Worksation with 1 Gb of RAM; the 18 Gb SCSI drive is 40% empty. I can run the merge (with data files of 7, 50, 125 and 175 records) over and over without any difficulty. As soon as I don't explicity name the file in the code, the error display before the file picker dialog would noramlly display.

    Is this typical with the file picker? I've used it successfully before, but only in Outlook. Might I have less difficulty if I revert to the FileOpen dialog with .Display? Code is below. The "problem" code is commented out.

    Thanks,
    Richard Barrett

    Sub ActiveDocumentMerge()
    Dim strForm As String
    strForm = ActiveDocument.FullName
    Dim strData As String
    Dim strOutput As String
    Dim sDir As String
    Dim sExt As String
    sExt = "*.doc , *.dat"
    Select Case Left$(Options.DefaultFilePath(wdStartupPath), 1)
    Case "i", "I"
    sDir = "i:my documents*.*"
    Case Else
    sDir = "c:mccarter temp*.*"
    End Select

    ' With Application.FileDialog(msoFileDialogFilePicker)
    ' .ButtonName = "Data File"
    ' .Filters.Clear
    '
    ' .Filters.Add "Word Documents", sExt, 1
    ' .InitialFileName = sDir
    ' If .Show = True Then
    ' strData = .SelectedItems(1)
    ' Else
    ' Exit Sub
    ' End If
    ' End With

    With ActiveDocument.MailMerge
    .OpenDataSource "c:Mccarter Tempdatatest.doc"
    ' .OpenDataSource Name:=strData
    .Destination = wdSendToNewDocument
    .SuppressBlankLines = True

    With .DataSource
    .FirstRecord = wdDefaultFirstRecord
    .LastRecord = wdDefaultLastRecord
    End With
    .Execute Pause:=False
    End With

    strOutput = ActiveDocument.FullName
    Documents(strForm).Saved = True
    Documents(strForm).Close
    Documents(strOutput).Activate
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FilePicker / Memory (Word 2002)

    I see nothing wrong with the code. I put it in a loop that repeats the dialog 20 times and didn't run into problems on a PC with 512 MB RAM.

    BTW, as far as I know, you should use a semicolon ; as separator in the list of extensions instead of a comma:
    <code>
    sExt = "*.doc;*.dat"</code>

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: FilePicker / Memory (Word 2002)

    Thank you. I failed to mention that I had re-booted a number of times, and this generally failed on the 2nd attempt, occasionally on the 3rd, and it was consistent in that.

    I degragged my drive, deleted tmp files... anything I could think of. The "not enough memory or disk space" error continues. Prior to running this merge code, I was running a macro that added merge codes to the active document (a letter, with merge fields for Addressee, Salutation, etc.) and wondered if that might have set things up. I have omitted that bit, and the error persists. I have not used wdDialogFileOpen, with the old WordBase code to grab the path/file name. The works as expected every time.

    I do know that I'm always going to be looking in the same folder, so I could write my own code to display a list of files in a custom dialog. The file picker, however, seemed like the logical way to go.

    I've opened the Task Manager while the "not enough memory" error was displayed and nothing seems remarkable.

    One related question: Should the user select a data file that is not appropriate for the merge form, is there a way for me to trap that as the merge begins? In such a situation, the user would see the "Header Record Delimiers" warning; can I intercept that warning and advise the user that an inappropriate data file has been selected?

    Thanks very much.
    Richard

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FilePicker / Memory (Word 2002)

    The "Header Record Delimiers" dialog is not an error message, so I don't see how one can intercept it. Perhaps you could use a dedicated folder for merge data source files, so that the user has to do more work to select an invalid data source (although I don't doubt they'll still succeed in doing so).

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FilePicker / Memory (Word 2002)

    I have no idea what causes your problem, but you could try using Dialogs(wdDialogFileOpen) with the Display method, as you suggested in your first post.

  6. #6
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: FilePicker / Memory (Word 2002)

    Dialogs(wdDalogfileOpne) works very well with repeated runs. I've Google'd the error regarding insufficient memory/disk space and have found plenty of information, although none of it seems really relevant. It seems to be associated with the Nimda virus, but the Symantec cleaner didn't find anything suspicious. Riched20.dll is apparently the associated Office DLL, so I'll run a Repair and see if that helps.

    Thanks again.
    Richard

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FilePicker / Memory (Word 2002)

    Riched20.dll is the dll for "rich text editing", i.e. a text box with formatted text. I don't think it has anything to do with the FileDialog object.

  8. #8
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: FilePicker / Memory (Word 2002)

    I'm grabbing at straws. The reasons I've found for "not enough memory" errors are 1. nimda virus, 2. corrupt riched20.dll, and 3. corrupt normal.dot. Everything that I have found relates the "not enough memory" to opening documents. That's not where I have the problem; it occurs when code displays the file picker dialog. Perhaps it's time to uninstall/reinstall Office or to re-format the drive completely.

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FilePicker / Memory (Word 2002)

    Reformat seems rather drastic (unless you were already thinking of doing that for other reasons). How badly do you need the file picker dialog?

  10. #10
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: FilePicker / Memory (Word 2002)

    I don't really *need* it right now, since I am happy with the workaround... but I expect that soon enough I really *will* need it, and I might as well be prepared. Also, if this is not behaving, I wonder what else might be lurking under my radar. I expect that a re-install of Office will be enough. Office is about the only application I have on this particular PC; I don't use it for anything other than VBA development. A reformat wouldn't be too much of a hardship.

    Richard

  11. #11
    5 Star Lounger st3333ve's Avatar
    Join Date
    May 2003
    Location
    Los Angeles, California, USA
    Posts
    705
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: FilePicker / Memory (Word 2002)

    I see from my notes that I've encountered "disk is full" error messages as a result of trying to save a template that has "a Reference set to a global template whose path has changed." And I swear that's not the only time Word and/or Access has hit me with a bogus message referring to a purported lack of disk space.

    If I were you, I wouldn't assume that the problem Word is having necessarily relates to a lack of memory or disk space.

  12. #12
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: FilePicker / Memory (Word 2002)

    I know that "disk is full" error as well. I am assuming that this current problem has nothing to do with memory or disk space. The question is what, then?

  13. #13
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: FilePicker / Memory (Word 2002)

    > I'm grabbing at straws.
    I don't know how Word manages memory. On the theory that your VBA procedure is allocated only a certain amount of memory -- and that Word/VB might be trying to swap something and getting confused about how to handle that -- can you think of any objects to destroy or ways to delete temporary memory (such as the Undo buffer) that might help reduce the need for that?

  14. #14
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: FilePicker / Memory (Word 2002)

    I have the problem immediately after re-botting and running this procedure once (first time is always successful). The only thing I can to destroy would be something left over from the previous run of this same code... and the only object is the File Picker itself. Could be that's not clearing out of memory when the procedure ends... or could be that this has nothing to do with memory.

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: FilePicker / Memory (Word 2002)

    You might try this:

    Dim fd As FileDialog
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    With fd

    .ButtonName = "Data File"
    .Filters.Clear
    .Filters.Add "Word Documents", sExt, 1
    .InitialFileName = sDir
    If .Show = True Then
    strData = .SelectedItems(1)
    Else
    Exit Sub
    End If
    End With
    Set fd = Nothing

    The added/modified lines (indicated in bold) ensure that the FileDialog object is destroyed after use.

Page 1 of 2 12 LastLast

Posting Permissions

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