• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

VBA - I dont want the destination workbook to be visible when opening to copy past|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / VBA - I dont want the destination workbook to be visible when opening to copy past|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosVBA - I dont want the destination w…
sp_PrintTopic sp_TopicIcon
VBA - I dont want the destination workbook to be visible when opening to copy past
Avatar
robert alvarez
Member
Members
Level 0
Forum Posts: 16
Member Since:
May 11, 2019
sp_UserOfflineSmall Offline
1
September 5, 2019 - 1:21 am
sp_Permalink sp_Print

Hi,

I have a project where I am copying data from one workbook to another using VBA.   

The syntax has data copying from one workbook, opening another workbook, pasting, then save, close.

The thing is that the other workbook is visible when it opens, and saves then closes.  I want it to be doing this in the background.   i tried a couple of criteria, but it hides the workbook completely, and to open it you need to manually unhide it.

 

Attached is the project.

For an overview, the user enters information in the calculator, presses a button which copies the info, opens an email, copies it to the body, then opens another workbook, and copies in a table under the last line.

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1845
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
September 5, 2019 - 4:26 am
sp_Permalink sp_Print

You have to open the file in another excel instance.

Dim xlApp as Excel.Application

set xlApp =New Excel.Application

To open the file in this excel instance:

set wb=xlapp.Workbooks.Open(filename)

Avatar
robert alvarez
Member
Members
Level 0
Forum Posts: 16
Member Since:
May 11, 2019
sp_UserOfflineSmall Offline
3
September 5, 2019 - 5:27 am
sp_Permalink sp_Print

Catalin Bombea said
You have to open the file in another excel instance.

Dim xlApp as Excel.Application

set xlApp =New Excel.Application

To open the file in this excel instance:

set wb=xlapp.Workbooks.Open(filename)  

 

Thank you Catalin,

so instead of using the one below I use the one you posted?

 

Sub OpenWorkbook()

Workbooks.Open "F:\Department Folders\Accounting\GMD Calculator Journal\GMD_Calculator_Journal.xlsx"

End Sub

 

Its that when I get down to the below copy past code, I get a debug error

 

Set wsCopy = Workbooks("GMD Fee Calculator V03.xlsm").Worksheets("Lookup")
Set wsDest = Workbooks("GMD_Calculator_Journal.xlsx").Worksheets("Sheet1")

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1845
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
4
September 5, 2019 - 2:41 pm
sp_Permalink sp_Print

One of the files is open in another instance of excel.

xlApp.Workbooks.Open "F:\Department Folders\Accounting\GMD Calculator Journal\GMD_Calculator_Journal.xlsx"

Set wsCopy = Workbooks("GMD Fee Calculator V03.xlsm").Worksheets("Lookup")
Set wsDest = xlApp.Workbooks("GMD_Calculator_Journal.xlsx").Worksheets("Sheet1")

If the excel application is missing, the code will associate the workbook with the same instance of the current workbook.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: QSolutions Group
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 185
Newest Members:
Kate Dyka
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6547
Posts: 28656

 

Member Stats:
Guest Posters: 49
Members: 32832
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.