Consulting

Results 1 to 7 of 7

Thread: I'm trying to do Magic! Not really....I want to create button macros in word

  1. #1

    I'm trying to do Magic! Not really....I want to create button macros in word

    I'm trying to create a document for my daughter. In doing this I'm copying/pasting a lot of pictures from one document to another. So I guess what I'm needing is help doing the following:

    1. create a macro in word and attach it to a button to switch between active documents easily. I need the VBA coding to do so something like "if docA=ActiveDocument, then make docB=Activedocument" and so on.

    2. create a document by cutting/pasting into another document. I have to make some formatting changes when pasting into the new document and they are all uniform. You know like every pic I paste, I have to change the wrapping style to tight, change size to the same width and same height, then position at some point on the page. What would be the code to create a macro for that?

    So any help with this would be greatly appreciated. Thanks in advance!

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Ctrl-F6 switches between documents. No macros required for that.

    If the pics are formatted in the source document with text wrapping, you should be able to select all of them in one go for copying, simply by selecting the first image, then holding down the Shift key as you select the others. After pasting, provided you don't change the selection, you should then be able to resize them all in one go. Again, no macros required. All you might still need to do is finalise the positioning.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Yes I know all that but I want to create a macro to shorten that process:

    this is the first one I want:
    1. insert picture
    2. open picture folder dialog
    3. select picture file name
    4. link to file and save with the file
    5. end

  4. #4

    Macro short cuts please! need help coding correctly

    this is the first one I want:
    1. insert picture
    2. open picture folder dialog
    3. select picture file name
    4. link to file and save with the file
    5. end

    this is as far as I got with coding:
    Sub PIXINS()
    '
    ' PIXINS Macro
    '
    '
    Selection.InlineShapes.AddPicture
    FILENAME:=
    LinkToFile:=False, SaveWithDocument:=True
    End Sub


    Help!!!!please

  5. #5
    The following should work for you. This inserts a linked selected image. It is not clear what you want to save.

    Option Explicit
    
    Sub PIXINS()
    '
    ' PIXINS Macro
    '
    '
    Dim strName As String
        strName = BrowseForImage("Select the image to insert")
        If strName = "" Then Exit Sub
        Selection.InlineShapes.AddPicture _
                FileName:=strName, _
                LinkToFile:=True, SaveWithDocument:=False
    End Sub
    
    Function BrowseForImage(Optional strTitle As String) As String
    'Graham Mayor
    'strTitle is the title of the dialog box
    Dim fDialog As FileDialog
        On Error GoTo err_Handler
        Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
        With fDialog
            .Title = strTitle
            .AllowMultiSelect = False
            .Filters.Clear
            .Filters.Add "Iamge Files", "*.png,*.jpg,*.tif,*.bmp,*.gif"
            .InitialFileName = Environ("USERPROFILE") & "\Pictures\"
            .InitialView = msoFileDialogViewLargeIcons
            If .Show <> -1 Then GoTo err_Handler:
            BrowseForImage = fDialog.SelectedItems.Item(1)
        End With
    lbl_Exit:
        Exit Function
    err_Handler:
        BrowseForImage = vbNullString
        Resume lbl_Exit
    End Function
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  6. #6
    See your other thread in this forum.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  7. #7
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Just4Pier: Kindly don't post questions about the same topic in multiple threads. I have merged the threads.
    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
  •