Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Apr 2001
    Location
    Ames, Iowa, USA
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro Help (Word97)

    I have a macro that amongst other things opens a data source for a mail merge.

    At this point in the macro the user must pick a different file each day to run the mail merge.

    Is there anyway to include in the opensourcedocument peice of the macro a switch to force the view to detail?

    The mail merge shouldn't be run if the file size is zero. The users are seemingly incapable of clicking the little button to change the view to details and want that to happen automatically. Yes... I know it should stay in what ever view you last used... but they hate seeing 'all that detail' (gheesh) and prefer to use list view. They can manage to change it to that by themselves.

    Or, anyway to halt the macro if the file size is 0? Then I have no 'view' issues.

    Users... gotta love 'em. <img src=/S/bif.gif border=0 alt=bif width=70 height=28>

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

    Re: Macro Help (Word97)

    Perhaps you can use or adapt this:

    You can check the size of a file using the FileLen function.

    strFileName = ...
    If FileLen(strFileName) = 0 Then
    Exit Sub
    End If

  3. #3
    Lounger
    Join Date
    Apr 2001
    Location
    Ames, Iowa, USA
    Posts
    34
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro Help (Word97)

    Thanks for the reply!

    Thought about that... but I don't know the name of the file until they select it... it's a new file each day. How do I make that check the file selected in the opensource document??

    I haven't had any luck with making the strFileName look at the selected file.

    JC

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

    Re: Macro Help (Word97)

    You can use the Display method of the FileOpen dialog to let the user select a data source without actually opening it.

    Then, you can inspect the file size and exit if necessary.

    The code could look like this:

    Dim strFileName As String
    With Dialogs(wdDialogFileOpen)
    ' Add preferred settings here before displaying the dialog, e.g.
    ' .Name = "C:Test*.doc"
    ' Display method returns -1 if user clicks OK
    If .Display = -1 Then
    ' Put selected file name in variable for further use
    strFileName = .Name
    ' Check if file is not empty
    If FileLen(strFileName) > 0 Then
    ' Open data source - add other arguments if needed
    ActiveDocument.MailMerge.OpenDataSource strFileName
    End If
    End If
    End With

    Adapt as needed.

Posting Permissions

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