Consulting

Results 1 to 2 of 2

Thread: What's wrong with that function ? I received a message that doc can not be defined

  1. #1

    What's wrong with that function ? I received a message that doc can not be defined

    Function number_dialogue()

    Dim font_type As String
    Dim super_type As String
    font_type = InputBox(prompt:="Пожалуйста, введите желаемую строку:", Title:="Ввод пользователем строки")
    super_type = InputBox(prompt:="Введите номер абзаца в конец, которого вы желаете перенести строку, максимально возможный номер сейчас: " & ThisDocument.Paragraphs.Count & " :", Title:="Выбор номера абзаца")

    Set doc = ThisDocument
    Set rngRange = _
    doc.Range(doc.Paragraphs(super_type).Start, _
    doc.Paragraphs(super_type).End - 1)
    rngRange.InsertAfter _
    " This is now the last sentence in paragraph one."


    End Function

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    doc.Range(doc.Paragraphs(super_type).Start
    should be:
    doc.Range(doc.Paragraphs(super_type).Range.Start


    doc.Paragraphs(super_type).End
    should be:
    doc.Paragraphs(super_type).Range.End


    In any event, you could greatly simplify that part of your code:
    Set rngRange = doc.Range(doc.Paragraphs(super_type).Range
    rngRange.End = rngRange.End -1
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •