2. How to open the PPT that contains macros will execute the corresponding macro, strives for the detailed steps?
CodePudding user response:
The first question has been solved, the codeSub AddSaveAsNewWord ()
Dim docPolicy As Document
Dim rngFormat As Range
Dim Filename As String
Filename=""
Dim As Long I
I=1
Dim TXT As String
TXT=""
Dim WordObject As Object 'declare an Object variable, here the statement As the Word Object
The Set WordObject=CreateObject (" Word. Application ")
'WordObject. Visible=0
Open "D: \ powerpoint \ passwd. TXT" For Input As # 1
'said to open the file using the channel number is 1
The Do While Not EOF (1)
The Line Input # 1, TXT
The Set docPolicy=WordObject. Documents. The Add (DocumentType:=wdNewBlankDocument)
'Set docPolicy=Documents. The Add
'set rngFormat variable location, located at the top of the document
The Set rngFormat=WordObject. ActiveDocument. Range (Start:=0, End:=0)
With rngFormat
. InsertAfter Text:="dzwebs"
End With
DocPolicy. Password=TXT
Filename="D: \ word " + Str (I) + ". Docx "
I=I + 1
DocPolicy. SaveAs Filename
DocPolicy. Close
Loop
Close # 1
The Set WordObject release object
=Nothing 'The Set docPolicy=Nothing
The Set rngFormat=Nothing
Application. The Quit SaveChanges:=wdDoNotSaveChanges' exit and close the Application document
End Sub