Results 1 to 4 of 4

Code to open a specific folder

Threaded View

  1. #1
    Registered User
    Join Date
    08-21-2014
    Location
    Montreal, Canada
    MS-Off Ver
    2007
    Posts
    6

    Question Code to open a specific folder

    Hope that someone can help,

    I've go a spreadsheet where I enter information for specific product to serve as a sale's sheet.
    The spreadsheet also contains a Macro Button (called "Insert Picture") that opens a folder so that I can select a picture to insert on my spreadsheet in the B8 cell.

    The problem that I have is that when I click the button, it opens a different folder whereas I need it to open as specific picture folder "L:\Pics".

    Does anybody know how I can modify the code so that it always opens my Picture folder ?

    Here is the current code:

    Sub Insert_N_Pict()
    Dim oPict, PictObj
    Dim sImgFileFormat As String
    Dim rPictCell As Range
    Dim iAns As Integer
    
    sImgFileFormat = "jpg Files (*.jpg), *.jpg, bmp (*.bmp),*.bmp,tif (*.tif),*tif"
    
    ActiveSheet.Range("B8").Select
    
    GetPict:
    oPict = Application.GetOpenFilename(sImgFileFormat)
    If oPict = False Then End
    
    iAns = MsgBox("Open : " & oPict, vbYesNo, "Insert Picture")
    If iAns = vbNo Then GoTo GetPict
    
    Set PictObj = ActiveSheet.Pictures.Insert(oPict)
    
    With PictObj
    .ShapeRange.LockAspectRatio = msoTrue
    .ShapeRange.Height = 255#
    End With
    
    Set PictObj = Nothing
    Set rPictCell = Nothing
    
    End Sub
    Thanks for any help
    Last edited by petitpiti; 11-20-2014 at 05:56 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Excel VBA code for selecting a folder then search & open specified files in that folder
    By Excelrookie_1 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-27-2021, 03:09 AM
  2. [SOLVED] Macro to open specific folder
    By siobeh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-16-2013, 04:22 PM
  3. [SOLVED] VBA Code open files in folder, copy text to workbook-Next time folder opened copy only new
    By Bikeman in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2013, 07:59 PM
  4. [SOLVED] Open specific folder, select file to open and copy then paste
    By Kranky in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 11-22-2012, 12:14 AM
  5. Open all worksheets in a specific folder
    By beegee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-09-2008, 06:26 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1