The starting point is different. VBA is usually hosted in another application that provides a set of built-in objects; for example, if your VBA is hosted in Word, you will have access to Word Application, which refers to the current Word application. In VBS, you must either create a new Application object and save it in a variable:
Dim wdApp
Set wdApp = CreateObject("Word.Application")
or get a link to an already running Word application:
Set wdApp = GetObject(,"Word.Application")
:
Dim wdDoc
Set wdDoc = wdApp.Open("path\to\document.docx")
, VBA . (
Dim wdDoc) VBA :
Dim wdDoc As Word.Document
'alternatively:
'Dim wdDoc As Document
, VBA , wdFormatDocument. VBScript :
Const wdFormatDocument = 0
:
wdApp.ActiveDocument.SaveAs2 FileName:="as90520.doc", FileFormat:= 0
Word
.
,
ActiveDocument Application (.
). VBS :
Dim wdApp
Set wdApp = CreateObject("Word.Application")
'When you open Word from the Start menu, it automatically adds a blank document for you
'When manipulating Word in a program, we need to do this by hand
'Generally we would store this in a variable, but we don't need to store it in order
'to use the ActiveDocument property; it just has to exist
wdApp.Documents.Add
'copied and pasted from before
wdApp.ActiveDocument.SaveAs2 FileName:="as90520.doc", FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False, CompatibilityMode:=0