Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Previously filled-in value in Input Box should show up as default on re-running the macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
andreas - 11 Dec 2006 21:06 GMT
Dear Experts:

I created a macro that formats the footnote numbers at the bottom of
the page differently/seperately from the footnote reference marks in
the main body of the text. This is done by using Input Boxes. The macro
is running fine.

Now here comes my question: I would like the user to see the previously
filled-in value in the InputBoxes whenever he/she re-activates the
macro. Now, only the default values show up when the InputBoxes are
activated. Is there a solution ?

Sub Dipl_Footnote_Number_Format_Separately()
'Format footnote numbers separately

Dim FootnoteFontSize As String
Dim FootnoteFontPosition As String
Dim i as Byte

FootnoteFontSize = InputBox("Please indicate the font size of the
footnote number" & vbCrLf & _
"This will cause the footnote numbers to be formatted differently from
the footnote reference marks in the main body of the text", "Font size
of the footnote number", 9)

FootnoteFontPosition = InputBox("Please indicate the position of the
footnote number ", _
"Position the footnote number", 3)

Selection.GoTo What:=wdGoToFootnote, Which:=wdGoToFirst, Count:=1,
Name:=""
       For i = 1 To ActiveDocument.Footnotes.Count

Selection.HomeKey unit:=wdLine
Selection.MoveRight unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.Font.Superscript = False

Selection.Font.Size = FootnoteFontSize
Selection.Font.Position = FootnoteFontPosition

Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.GoTo What:=wdGoToFootnote, Which:=wdGoToNext, Count:=1,
Name:=""

Next i

End Sub

Again, my question: I would like the user to see the previously
filled-in value in the InputBoxes whenever he/she re-activates the
macro. Now, only the default values show up when the InputBoxes are
activated. Is there a solution ?

Help is appreciated. Thanks a lot in advance.

Regards,

Andreas
Greg Maxey - 11 Dec 2006 21:42 GMT
Something like this might work:

Store the value of the input box in a doc variable and then set the
defualt to the variable value:

Sub ScrathMacro()
Dim oVar As Variable
On Error GoTo Err_Handler
Set oVar = ActiveDocument.Variables("Store1")
oVar.Value = InputBox("Enter as value", "Value", oVar.Value)
FootNoteFontPostion = oVar.Value
Exit Sub
Err_Handler:
If Err.Number = 5825 Then
 oVar.Value = "Default value"
 Resume
End If
End Sub

> Dear Experts:
>
[quoted text clipped - 54 lines]
>
> Andreas
andreas - 12 Dec 2006 12:16 GMT
Dear Greg,

great it is working, VERY GOOD JOB,  BUT being more or less a novice at
VBA I do not know how to store the value of the second input box in a
second doc variable and then set the default to  that variable value. I
tried a couple of things, but to no avail.

As you can see from the below code I integrated your code already but
as I said, the "FootnoteFontPosition" InputBox also needs to be
adressed.

Thank you in advance

Regards,

Andreas

Sub xxx_Format_Footnote_number()

'Your comments:
'Something like this might work:
'Store the value of the input box in a doc variable and then set the
'default to the variable value:

Dim oVar As Variable
Dim FootnoteFontPosition As String

On Error GoTo Err_Handler
Set oVar = ActiveDocument.Variables("Store1")
oVar.Value = InputBox("Enter as value", "Value", oVar.Value)

FootnoteFontPosition = InputBox("Please indicate the position of the
footnote", _
"Position footnote number", 3)

If ActiveWindow.ActivePane.View.Type = wdPrintView Or ActiveWindow. _
       ActivePane.View.Type = wdWebView Or
ActiveWindow.ActivePane.View.Type = _
       wdPrintPreview Then
       ActiveWindow.View.SeekView = wdSeekFootnotes
       End If

       Selection.GoTo What:=wdGoToFootnote, Which:=wdGoToFirst,
Count:=1, Name:=""
       For i = 1 To ActiveDocument.Footnotes.Count

Selection.HomeKey unit:=wdLine
Selection.MoveRight unit:=wdCharacter, Count:=2, Extend:=wdExtend
Selection.Font.Superscript = False

Selection.Font.Size = oVar.Value
Selection.Font.Position = FootnoteFontPosition

Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.GoTo What:=wdGoToFootnote, Which:=wdGoToNext, Count:=1,
Name:=""
Next
Exit Sub

Err_Handler:
If Err.Number = 5825 Then
 oVar.Value = "Default value"
 Resume
End If
End Sub

Greg Maxey schrieb:

> Something like this might work:
>
[quoted text clipped - 73 lines]
> >
> > Andreas
Greg Maxey - 12 Dec 2006 13:40 GMT
Andreas,

Just repeat for the second variable what you do for the first:

Sub Dipl_Footnote_Number_Format_Separately()
Dim oVar1 As Variable
Dim oVar2 As Variable
Dim FootnoteFontSize As String
Dim FootnoteFontPosition As String

On Error GoTo Err_Handler1
Set oVar1 = ActiveDocument.Variables("Store1")
oVar1.Value = InputBox("Enter as value", "Value", oVar1.Value)
FootnoteFontSize = oVar1.Value

On Error GoTo Err_Handler2
Set oVar2 = ActiveDocument.Variables("Store2")
oVar2.Value = InputBox("Enter as value", "Value", oVar2.Value)
FootnoteFontPosition = oVar2.Value

'Your code to apply the variables defined above

Exit Sub
Err_Handler1:
If Err.Number = 5825 Then
 oVar1.Value = "9"
 Resume
End If
Exit Sub
Err_Handler2:
If Err.Number = 5825 Then
 oVar2.Value = "3"
 Resume
End If
End Sub

> Dear Greg,
>
[quoted text clipped - 141 lines]
> > >
> > > Andreas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.