1. DLP Flash Christmas Competition + Writing Marathon 2024!

    Competition topic: Magical New Year!

    Marathon goal? Crank out words!

    Check the marathon thread or competition thread for details.

    Dismiss Notice
  2. Hi there, Guest

    Only registered users can really experience what DLP has to offer. Many forums are only accessible if you have an account. Why don't you register?
    Dismiss Notice
  3. Introducing for your Perusing Pleasure

    New Thread Thursday
    +
    Shit Post Sunday

    READ ME
    Dismiss Notice

VBA code/Macro

Discussion in 'Tech Support' started by Joe's Nemesis, May 27, 2015.

  1. Joe's Nemesis

    Joe's Nemesis High Score: 2,058 ~ Prestige ~

    Joined:
    Jan 29, 2012
    Messages:
    1,191
    High Score:
    2,058
    In Word (2013), I'm trying to write a macro that will insert a footnote and then send the keystrokes, "Alt + 0."

    The footnote is no problem. But I can't, for the life of me, figure out how to get the macro to send the Alt + 0 keystrokes.

    The closest I came was

    With Selection
    With .FootnoteOptions
    .Location = wdBeneathText
    .NumberingRule = wdRestartContinuous
    .StartingNumber = 1
    .NumberStyle = wdNoteNumberStyleArabic
    .LayoutColumns = 0
    End With
    .Footnotes.Add Range:=Selection.Range, Reference:=""
    End With
    InputSimulator.SimulateModifiedKeyStroke = (VirtualKeyCode.MENU + VirtualKeyCode.VK_U)

    And it's kicking out an error "Run-Time Error 424) Object Required.

    I've tried moving the last line of code up before "End With" I've also tried running it in its own "With Selection" (although, since it is only kicking off a command line to open up Endnote citations within Word, I'm not sure I need "With Selection.")

    Any help would be appreciated.
     
  2. Jeram

    Jeram Elder of Zion ~ Prestige ~ DLP Supporter

    Joined:
    Jun 27, 2006
    Messages:
    143
    High Score:
    1756
    I don't think you're doing that quite right. InputSimulator isn't something you can reference in VBA, it's a C# library.

    SendKeys "%0"
    will send Alt-0.
     
  3. Joe's Nemesis

    Joe's Nemesis High Score: 2,058 ~ Prestige ~

    Joined:
    Jan 29, 2012
    Messages:
    1,191
    High Score:
    2,058
    . . . you were being nice. I wasn't doing it right at all, but thanks! About the same time I saw this, I realized I was using two different templates and the macros I was trying to call, but couldn't find, were simply on another template. So, once I switched over to look at them, I could pull them up and use them.

    Turns out, all I needed was:
    Application.Run "ENfindCitations"

    That, added to the rest of the macro, lets me hit a hotkey and now put in both the footnote and the citation in one process.
     
Loading...
Similar Threads
  1. Breed
    Replies:
    10
    Views:
    2,657