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 / July 2007

Tip: Looking for answers? Try searching our database.

Displaying InputBox Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stacy - 19 Jul 2007 23:22 GMT
I am new at this and trying to create a macro in work that will insert a new
appendix cover sheet in a report template.  Allowing the user to type the
Appendix letter and name to display for the title and footer.  How do I get
the InputBox data entered to appear in my Word document?
See code below.  Or is it totally off?

   Selection.EndKey Unit:=wdStory
   Selection.InsertBreak Type:=wdSectionBreakNextPage
   Selection.TypeText Text:="Appendix "
   
   MyValue = InputBox("Type Letter of Appendix", "Insert Appendix")
   
   Selection.TypeText Text:=": "
   
       Message = "Type Name of the Appendix"
       Title = "Insert Appendix Name"
       MyValue = InputBox(Message, Title)
   
   Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
   Selection.Style = ActiveDocument.Styles("TOC Title")
   Selection.EndKey Unit:=wdStory
   Selection.TypeParagraph

   If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
       ActiveWindow.Panes(2).Close
   End If
   If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
       ActivePane.View.Type = wdOutlineView Then
       ActiveWindow.ActivePane.View.Type = wdPrintView
   End If
   Selection.EndKey Unit:=wdStory
   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   If Selection.HeaderFooter.IsHeader = True Then
       ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
   Else
       ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   End If

   Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
       LinkToPrevious
       
   Selection.MoveLeft Unit:=wdCharacter, Count:=3
   Selection.TypeBackspace
       Message = "Type Letter of Appendix"
       Title = "Insert Appendix Letter in Footer"
       MyValue = InputBox(Message, Title)
   
   ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
       
End Function

Signature

SC

zkid - 26 Jul 2007 17:38 GMT
I think all you're missing is this after you've asked the question (input):

Selection.TypeText MyValue

> I am new at this and trying to create a macro in work that will insert a new
> appendix cover sheet in a report template.  Allowing the user to type the
[quoted text clipped - 46 lines]
>        
> End Function
 
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.