Solved

Is there a way to pick up the date picture was created when importing a picture via VBA

Posted on 2010-11-22
2
260 Views
Last Modified: 2012-08-13
Hi experts

I'm using the VBA code below to insert a picture into Word. I'm wondering if there is a way to pick up the date the picture was created as if it is before a certain date I need to handle it differently.
Dim oDialog As Word.Dialog, lngPictureSize As Double

 Set oDialog = Dialogs(wdDialogInsertPicture)

 Dim pic As InlineShape

 

  With oDialog

    .Display

    

Application.ScreenUpdating = False

    

    If .Name <> "" Then

             Set pic = ActiveDocument.InlineShapes.AddPicture(FileName:=.Name, _

            LinkToFile:=False, _

            SaveWithDocument:=True, _

            Range:=Selection.Range)

Open in new window

0
Comment
Question by:Fi69
2 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 250 total points
Comment Utility
This line:

            LinkToFile:=False, _

means that you can't do it later.


But you can do this to decide whether the picture is new enough to add to the document.
Dim oDialog As Word.Dialog, lngPictureSize As Double

    Dim pic As InlineShape

    Dim myDate As Date

    

    myDate = DateSerial(2009, 11, 23)

    

    Set oDialog = Dialogs(wdDialogInsertPicture)

    With oDialog

        .Display

        Application.ScreenUpdating = False

        If .Name <> "" Then

            If FileDateTime(.Name) > myDate Then

            

            Set pic = ActiveDocument.InlineShapes.AddPicture(FileName:=.Name, _

                      LinkToFile:=False, _

                      SaveWithDocument:=True, _

                      Range:=Selection.Range)

Open in new window

0
 

Author Closing Comment

by:Fi69
Comment Utility
Perfect.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now