• 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Create and Store the Three File Formats in my Word / Excel / PDF folder|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Create and Store the Three File Formats in my Word / Excel / PDF folder|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
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 & MacrosCreate and Store the Three File For…
sp_PrintTopic sp_TopicIcon
Create and Store the Three File Formats in my Word / Excel / PDF folder
Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
1
April 25, 2021 - 4:17 am
sp_Permalink sp_Print

Hi Everyone my new problem is this:

On an excel sheet with Office 2007 I entered numbers ranging from cell (A1: E18)
And Three Shape Buttons
Now the purpose of this project and that I would like to be able to achieve is this:
1) By pressing the first key It should from Routine Create a Word Sheet and insert it in my sub Folder with only the data taken from the cells (A1: E18) and save it with the name I insert in the cell (I1)

2) The Same Thing You Should Be Achieving with an Excel Sheet

3) Also for what concerns the file in pdf format which in some ways is the only one that I was able to make work Except for the fact that I would like it to take into consideration only the numbered cells and not the whole sheet.

I wish you could also insert the image both in the saved Excel sheet and in the Word and PDF sheet
A bit like I did it manually in the various formats that you find in the subfolder called (Attachments) all here
Thank you for all the help you will want to give me on this
Greetings from A.Maurizio

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1810
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
2
April 28, 2021 - 1:53 pm
sp_Permalink sp_Print sp_EditHistory

To write into word, save to folder:
Range("A1:C20").Copy
Scrittura.Selection.Paste
Documento.SaveAs ThisWorkbook.Path & "\Allegati\" & Range("I1").Value

 

For excel, instead of copying the sheet (activesheet.copy):
Dim Rng As Range: Set Rng = ActiveSheet.Range("A1:E18")
Workbooks.Add
Rng.Copy ActiveWorkbook.Worksheets(1).Range("A1")
ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\Allegati\" & Range("I1").Value

 

For PDF, you have to set the printable area of the excel sheet to A1:E18, only that range will be printed to pdf.

Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
3
April 30, 2021 - 1:09 am
sp_Permalink sp_Print

Hello Catalin Bombea
Thanks for your suggestions, they have really been useful to me
It was a bit challenging to understand and how to put the concept into practice (Scripture Select) e
(Documento.Save) as I couldn't figure out how to put the pieces together.
Then I figured it all out and now it works great.
Thank you so much
Greetings from Maurizio

Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
4
May 1, 2021 - 1:03 am
sp_Permalink sp_Print

Hi Catalin Bombea I thought I could get by on my own; But without you I lose myself in a glass of water:
My Problem is this:
With this Code Following your instructions yesterday I can open the new Excel sheet; But nothing appears inside
This is the code:

Option Explicit Sub CopyToExcel() On Error GoTo 1 Dim oXL As Excel.Application Dim oWB As Excel.Workbook Dim oSheet As Excel.Worksheet Dim oRng As Excel.Range Dim Rng As Range Dim NomeFile As String Set oXL = CreateObject("Excel.Application") 'New Excel.Document oXL.Application.Visible = True Set oWB = oXL.Workbooks.Add Set oSheet = oWB.ActiveSheet Set Rng = ActiveSheet.Range("A1:I26") NomeFile = Foglio1.Range("M1").Value oSheet.Activate 'For Each Rng In ActiveWorkbook.Worksheets Foglio1.Range("A1:I26").Select Rng.ActiveSheet.Copy 'oWB.ActiveSheet.Copy ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\Allegati\" & NomeFile & ".xlsm" 'doc.Close 'Next Rng 1: End Sub

Why This Happens And Where Am I Wrong Thanks

Avatar
Catalin Bombea
Iasi, Romania
Admin
Level 10
Forum Posts: 1810
Member Since:
November 8, 2013
sp_UserOfflineSmall Offline
5
May 1, 2021 - 1:51 am
sp_Permalink sp_Print

What you are doing wrong is that you did not used the code provided that was functional.

Instead, you are using a different method, but instead of copying from source you are copying from the new workbook, which is blank obviously.

Look at this line:
Set Rng = ActiveSheet.Range("A1:I26")

There is a reason why this line is BEFORE adding a new workbook: because when you add a new workbook, THE NEW book becomes active. We need to copy from Active sheet: Set Rng = ActiveSheet.Range("A1:I26"), but because you have this line AFTER adding the new sheet, you are copying from the new blank book.

NomeFile = Foglio1.Range("M1").Value

1 Set Rng = ActiveSheet.Range("A1:I26")

2 Set oWB = oXL.Workbooks.Add

3 Set oSheet = oWB.worksheets(1)

4 Rng.Copy oSheet.Range("A1")

5 oWB.SaveAs Filename:=ThisWorkbook.Path & "\Allegati\" & NomeFile

Avatar
A.Maurizio
Member
Members
Level 0
Forum Posts: 202
Member Since:
June 26, 2016
sp_UserOfflineSmall Offline
6
May 1, 2021 - 4:41 pm
sp_Permalink sp_Print

I'm sorry but while you make your changes to me nothing happens

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Alexandra Radu
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Raj Mattoo
Mark Luke
terimeri dooriyan
Jack Aston
AndyC
Denise Lloyd
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Forum Stats:
Groups: 3
Forums: 24
Topics: 6219
Posts: 27276

 

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

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • 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
 

Company

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

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.