H
herman404
Hi everyone, I am trying to write a function that will be called from
another function. It will do a save as on a word document, and the
document name will be passed via a parameter. I keep getting a Type
Mismatch error on the Documents.Open call below, but it works fine when
I specify the name of the file in the Open call. How come it doesn't
work with the parameter, even when I declare a local variable and set
it equal to the parameter? The parameter is confirmed as being a
string using vartype.
Function ConvertWordFile(Filename)
Const wdFormatText = 2
Dim fname
Dim objWord
Dim objDoc
Set fname = Filename
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(fname)
objWord.Visible = FALSE
objDoc.SaveAs Filename+".txt", wdFormatText
objWord.Quit
End function
another function. It will do a save as on a word document, and the
document name will be passed via a parameter. I keep getting a Type
Mismatch error on the Documents.Open call below, but it works fine when
I specify the name of the file in the Open call. How come it doesn't
work with the parameter, even when I declare a local variable and set
it equal to the parameter? The parameter is confirmed as being a
string using vartype.
Function ConvertWordFile(Filename)
Const wdFormatText = 2
Dim fname
Dim objWord
Dim objDoc
Set fname = Filename
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(fname)
objWord.Visible = FALSE
objDoc.SaveAs Filename+".txt", wdFormatText
objWord.Quit
End function