ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Anyone know how to convert word 2007 macros to use in Outlook 2007?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyone know how to convert word 2007 macros to use in Outlook 2007?

    Anyone know how to program macros in Outlook 2007?

    I have a macro for Word that I use to paste screen shots (copy text from green screen and paste into emails) as it is smaller than emailing images, and the text can then also be copied at the other end.

    In word this creates a 1 cell table, pastes the text into the table, shades the table background grey, puts a thin border on the table, changes the font to courier new (to preserve green screen formatting) and make it font size 10.

    When we changed to outlook 2007 from 2003 it was no longer available.

    Anybody know how to convert the below word 2007 macro for use in outlook?

    PHP Code:
    Sub TextBox()
    //'
    //' TextBox Macro
    //'   Recorded by Greg Craill 14/11/2010
    //'   Pastes the selected text into a text box and formats it as a screen shot type.
    //'
        
    ActiveDocument.Tables.Add Range:=Selection.RangeNumRows:=1NumColumns:= _
            1
    DefaultTableBehavior:=wdWord9TableBehaviorAutoFitBehavior:= _
            wdAutoFitFixed
        With Selection
    .Tables(1)
            If .
    Style <> "Table Grid" Then
                
    .Style "Table Grid"
            
    End If
            .
    ApplyStyleHeadingRows True
            
    .ApplyStyleLastRow False
            
    .ApplyStyleFirstColumn True
            
    .ApplyStyleLastColumn False
            
    .ApplyStyleRowBands True
            
    .ApplyStyleColumnBands False
        End With
        With Selection
    .Tables(1)
            .
    TopPadding CentimetersToPoints(0.2)
            .
    BottomPadding CentimetersToPoints(0.2)
            .
    LeftPadding CentimetersToPoints(0.2)
            .
    RightPadding CentimetersToPoints(0.2)
            .
    Spacing 0
            
    .AllowPageBreaks True
            
    .AllowAutoFit True
        End With
        Selection
    .Tables(1).AutoFitBehavior (wdAutoFitContent)
        
    Selection.PasteAndFormat (wdPasteDefault)
        
    Selection.TypeBackspace
        Selection
    .Tables(1).Select
        Selection
    .Font.Name "Courier New"
        
    Selection.Font.Size 10
        Selection
    .Font.Color = -587137025
        Selection
    .Shading.Texture wdTextureNone
        Selection
    .Shading.ForegroundPatternColor wdColorAutomatic
        Selection
    .Shading.BackgroundPatternColor = -603923969
        Selection
    .MoveDown Unit:=wdLineCount:=1
    End Sub 
    Greg Craill: "Life's hard - Get a helmet !!"

  • #2
    Re: Anyone know how to convert word 2007 macros to use in Outlook 2007?

    Guy named Eric Legault gave me this solution. You have to make sure the reference libraries below are checked. Top work Eric!
    • Visual Basic For Applications
    • Microsoft Outlook 12.0 Object Library
    • OLE Automation
    • Microsoft Office 12.0 Object Library
    • Microsoft Word 12.0 Object Library

    PHP Code:
    Sub PasteAsTextBox() 

    Dim objDoc As Word.Document 
    Dim objWord 
    As Word.Application
    Dim objRange 
    As Word.Range

    Set objDoc 
    ActiveInspector.WordEditor
    Set objWord 
    objDoc.Application
    Set objRange 
    objWord.Selection.Range objDoc.Tables.Add objRange11wdWord9TableBehaviorwdAutoFitFixed

    With objWord
    .Selection.Tables(1)
      If .
    Style <> "Table Grid" Then
       
    .Style "Table Grid"
      
    End If
      .
    ApplyStyleHeadingRows True
      
    .ApplyStyleLastRow False
      
    .ApplyStyleFirstColumn True
      
    .ApplyStyleLastColumn False
      
    .ApplyStyleRowBands True
      
    .ApplyStyleColumnBands False
    End With

    With objWord
    .Selection.Tables(1)
      .
    TopPadding objWord.CentimetersToPoints(0.2)
      .
    BottomPadding objWord.CentimetersToPoints(0.2)
      .
    LeftPadding objWord.CentimetersToPoints(0.2)
      .
    RightPadding objWord.CentimetersToPoints(0.2)
      .
    Spacing .AllowPageBreaks True
      
    .AllowAutoFit True
    End With

    objWord
    .Selection.Tables(1).Rows.LeftIndent InchesToPoints(1)
    objWord.Selection.Tables(1).AutoFitBehavior (wdAutoFitContent)
    objWord.Selection.PasteAndFormat (wdPasteDefault)
    objWord.Selection.TypeBackspace
    objWord
    .Selection.Tables(1).Select
    objWord
    .Selection.Font.Name "Courier New"
    objWord.Selection.Font.Size 10
    objWord
    .Selection.Font.Color = -587137025
    objWord
    .Selection.Shading.Texture wdTextureNone
    objWord
    .Selection.Shading.ForegroundPatternColor wdColorAutomatic
    objWord
    .Selection.Shading.BackgroundPatternColor = -603923969
    objWord
    .Selection.MoveDown Unit:=wdLineCount:=1

    End Sub 
    Greg Craill: "Life's hard - Get a helmet !!"

    Comment

    Working...
    X