+ Reply to Thread
Results 1 to 2 of 2

Code not executing between File Open and File Save As

  1. #1
    Registered User
    Join Date
    11-24-2023
    Location
    Houston, TX
    MS-Off Ver
    Office 365
    Posts
    2

    Code not executing between File Open and File Save As

    I have the following code, which seems to be working property in segments. The File Open/File Save As seems to be working, but the code in the middle to resize the images isn't. I think the document is being closed with the Save As, and I'm not keeping it as the Active Document after the File Open. I'm not sure exactly how to do that.

    If I comment out the File Open and File Save As code, I can resize the images as intended by the middle section of code. So, if I'm in the Normal.dotm document, and I'm opening another document to act on it, how do I make that (the opened document) the Active Document for the macro?


    Please Login or Register  to view this content.
    Last edited by gshockxcc; 12-20-2023 at 09:40 AM. Reason: Added detail

  2. #2
    Forum Contributor
    Join Date
    02-04-2017
    Location
    chennai
    MS-Off Ver
    MS OFFICE 365
    Posts
    253

    Re: Code not executing between File Open and File Save As

    It looks like you're on the right track, but you're correct in identifying the issue with the Active Document. After opening a new document, you need to set it as the Active Document so that subsequent operations are performed on it. Here's an updated your code:
    Please Login or Register  to view this content.
    This code opens the selected file, sets it as the Active Document, resizes the images, saves the changes, and then proceeds with saving the active document as .docm. If you want to close the opened document afterward, you can uncomment the openedDoc.Close line.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] need a VBA code to open, and save a file in specific folder using cell file paths
    By JSD100 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-27-2022, 10:49 AM
  2. Replies: 8
    Last Post: 12-02-2019, 03:42 PM
  3. Macro Code to Open file with dynamic name (and possibly re-save with different name)
    By mm671750 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-27-2013, 01:40 PM
  4. [SOLVED] Executing a SaveAs Command in an Open .txt File
    By HannahTee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-18-2013, 10:57 PM
  5. Problem With Open File and Save File With Saveas and then close the File
    By John Vieren in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-27-2013, 12:53 AM
  6. Open file after workbook executing code is closed
    By randell.graybill in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2011, 10:05 PM
  7. How to: Open file, format data, save file, close file and repeat.
    By thexeber in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-11-2010, 12:56 PM

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