Hey,


I have the following problem.
If I use a VB-executable (VB 6.0) to auto merge doc-files with csv-files, I get the following error:
Run-time error '6294', Filetype and extention are incompatible.
The problem is only with the 64-bit-version of Word 2010.
The 32-bit-versions works fine.

Here the code.

Code:
Function GetCommandLine(Optional MaxArgs)
   'Declare variables.
   Dim C, CmdLine, CmdLnLen, InArg, I, NumArgs
   'See if MaxArgs was provided.
   If IsMissing(MaxArgs) Then MaxArgs = 10
   'Make array of the correct size.
   ReDim ArgArray(MaxArgs)
   NumArgs = 0: InArg = False
   'Get command line arguments.
   CmdLine = Command()
   CmdLnLen = Len(CmdLine)
   'Go thru command line one character
   'at a time.
   For I = 1 To CmdLnLen
      C = Mid(CmdLine, I, 1)
      'Test for space or tab.
      If (C <> ";") Then
         'Neither space nor tab.
         'Test if already in argument.
         If Not InArg Then
         'New argument begins.
         'Test for too many arguments.
            If NumArgs = MaxArgs Then Exit For
            NumArgs = NumArgs + 1
            InArg = True
         End If
         'Concatenate character to current argument.
         ArgArray(NumArgs) = ArgArray(NumArgs) & C
      Else
         'Found a space or tab.
         'Set InArg flag to False.
         InArg = False
      End If
   Next I
   'Resize array just enough to hold arguments.
   ReDim Preserve ArgArray(NumArgs)
   'Return Array in Function name.
   GetCommandLine = ArgArray()
End Function


Private Sub Form_Activate()
Dim cArray As Variant
Dim cDocName As String
Dim cGegName As String
Dim cMergeName As String
Dim bPreview As Boolean
Dim cTaal As String

cArray = GetCommandLine()

cDocName = cArray(1)
cGegName = cArray(2)
cMergeName = cArray(3)
bPreview = cArray(4)
cTaal = cArray(5)

'Testen op taal

If cTaal = "F" Then
  lblMelding.Caption = "Veuillez patienter ..."
Else
  lblMelding.Caption = "Even geduld ..."
End If

lblMelding.Refresh


Dim oWordApp As Word.Application
Dim oWordDoc As Word.Document

Set oWordApp = New Word.Application
Set oWordDoc = New Word.Document

oWordApp.Documents.Open (cDocName)
oWordApp.ActiveDocument.MailMerge.OpenDataSource (cGegName)
oWordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
oWordApp.ActiveDocument.MailMerge.Execute
oWordApp.Visible = True
oWordApp.ActiveDocument.SaveAs (cMergeName)
' Gemergde file sluiten
oWordApp.ActiveDocument.Close (False)
' Te mergen file sluiten
oWordApp.ActiveDocument.Close (False)

If bPreview Then
  oWordApp.Documents.Open (cMergeName)
  oWordApp.Visible = True
  oWordApp.Activate

Else
  oWordApp.Documents.Open (cMergeName)
  oWordApp.ActiveDocument.PrintOut (False)
  
  Do While oWordApp.BackgroundPrintingStatus > 0
    ' Wachten
  Loop
  
  oWordApp.ActiveDocument.Close (False)
  oWordApp.Quit
End If

Unload Me

End Sub
Thank you !

Greetings,


S. Vermassen