Developer technologies | Visual Basic for Applications
An implementation of Visual Basic that is built into Microsoft products.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Here is my VB code:
Dim artistName As Range
Set artistName = ActiveDocument.Bookmarks("artistName").Range
artistName.Text = Me.TextBox1.Value
Dim artistAddress As Range
Set artistAddress = ActiveDocument.Bookmarks("artistAddress").Range
artistAddress.Text = Me.TextBox4.Value
Dim recordingFund As Range
Set recordingFund = ActiveDocument.Bookmarks("recordingFund").Range
recordingFund.Text = Me.TextBox2.Value
Dim marketingBudget As Range
Set marketingBudget = ActiveDocument.Bookmarks("marketingBudget").Range
marketingBudget.Text = Me.TextBox3.Value
Dim revShare As Range
Set revShare = ActiveDocument.Bookmarks("revShare").Range
revShare.Text = Me.TextBox5.Value
Dim rightsPeriod As Range
Set rightsPeriod = ActiveDocument.Bookmarks("rightsPeriod").Range
rightsPeriod.Text = Me.TextBox6.Value
Dim territory As Range
Set territory = ActiveDocument.Bookmarks("territory").Range
territory.Text = Me.TextBox7.Value
Me.Repaint
Dim strDocName As String
Dim intPos As Integer
' Find position of extension in file name
strDocName = ""
intPos = InStrRev(strDocName, ".")
If intPos = 0 Then
' If the document has not yet been saved
' Ask the user to provide a file name
strDocName = InputBox("Please enter the name " & _
"of your document.")
Else
' Strip off extension and add ".txt" extension
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".docx"
End If
' Save file with new extension
ActiveDocument.SaveAs2 FileName:=strDocName, _
FileFormat:=wdFormatDocumentDefault
stInfo.Hide
infoForm.Show
End Sub
An implementation of Visual Basic that is built into Microsoft products.