hello,
I'm struggling with changing my excel VBA code to word (don't hate me i'm a beginner )
that's my code it works in excel but not in word.
can anybody please help me to fix it? it's tripping on filename=textbox1.text
original excel code:
my word test
I'm struggling with changing my excel VBA code to word (don't hate me i'm a beginner )
that's my code it works in excel but not in word.
can anybody please help me to fix it? it's tripping on filename=textbox1.text
original excel code:
Code:
Private Sub CommandButton1_click()
Dim path as string
Dim filename as string
path = "C:kjsdfhdfghld"
filename = range("d2").text
Application.displayAlerts = false
ActiveWorkbook.saveAs Filename:=path & filename & ".xls", fileFormat:=xlopenXMLWorkbook
Application.displayAlerts = true
ActiveWorkbook.close
End Sub
Code:
Sub test()
Dim path As String
Dim filename As String
path = "G:\Management\"
filename = TextBox1.Text
Application.DisplayAlerts = False
ActiveDocument.SaveAs filename:=path & filename & ".doc", fileFormat:=docDocument
Application.DisplayAlerts = True
ActiveDocument.Close
End Sub
Last edited by a moderator: