excel-vba

VBA: Within Excel how do I save a word document as a PDF?

元气小坏坏 提交于 2020-01-24 17:11:06
问题 I have some code that copies and pastes data from an Excel file into a word document, how can I get that word document to save as a PDF? My code is as follows: Sub RetailerGraphs() Dim Location As String Dim Detail As String Worksheets("-Summary").Activate Range("AE9").Select While ActiveCell.Value <> "" ActiveCell.Offset(1, 0).Select Location = ActiveCell.Value Worksheets("Detail Summary").Activate Range("B7").Value = Location Dim objWord, objDoc As Object ActiveWindow.View = xlNormalView

Excel Index / Table of Contents - Macro

时光毁灭记忆、已成空白 提交于 2020-01-24 16:17:07
问题 I was reading up some codes that used a macro to auto-create a table of contents. I have a workbook with multiple sheets and new sheets are being added everyday. Each sheet name is a unique number and has an identical template inside. The codes I saw would only give the option of collating an index with the Sheet Name. I was wondering if I could get an option that would also pick up one or two values from each sheet, like this: Sr No. Sheet Name Cell A1 Cell A2 Cell A3 I need the Macro to run

When two workbooks are opened in visual basic, workbook variables do not get assigned correctly

心不动则不痛 提交于 2020-01-24 14:16:19
问题 When running the code below, I get different results depending on which workbooks are open. The sub is in a module associated with Master Sheet.xlsm If just the Master Sheet.xlsm open then the code runs correctly, i.e. the Message Boxes say (where comma separates the first and second message box): Master Sheet, transferred cases 03-09-18 If both Master Sheet.xlsm and transferred cases 03-09-18.xlsx are open but transferred cases 03-09-18.xlsx was open second then the message boxes say:

When two workbooks are opened in visual basic, workbook variables do not get assigned correctly

↘锁芯ラ 提交于 2020-01-24 14:16:06
问题 When running the code below, I get different results depending on which workbooks are open. The sub is in a module associated with Master Sheet.xlsm If just the Master Sheet.xlsm open then the code runs correctly, i.e. the Message Boxes say (where comma separates the first and second message box): Master Sheet, transferred cases 03-09-18 If both Master Sheet.xlsm and transferred cases 03-09-18.xlsx are open but transferred cases 03-09-18.xlsx was open second then the message boxes say:

Automatically Replace Misspellings with Suggestions for long lists of terms

六眼飞鱼酱① 提交于 2020-01-24 14:00:08
问题 I have a long list of terms. Over 90% are misspellings. Most of which are two words that have no space in the middle. I noticed that MS Word, Excel, Office, etc. is pretty good at suggesting the correct spelling. When I run the spellchecker, I don't have time to confirm each and every suggested correction. Having some errors are OK. How can I automate spellcheck, or rather "spellcorrect" without prompting? I don't mind using other tools besides Microsoft, but it's spellchecker seems pretty

VBA to loop through a folder find a worksheet open it and move all tabs to another workbook

≯℡__Kan透↙ 提交于 2020-01-24 13:12:21
问题 I'm working on a project that requires the following: I would like a Macro to loop through a folder and search for a certain worksheet then grab all the tabs from this worksheet and move them to a consolidated workbook Is it possible to find a worksheet based on a certain string in the worksheet name? ex: Financial_data_401kk.xls Could you search by this string "401kk"? Im new to VBA and this is what i have so far Sub ConsolidateSheets() Dim Path as String Dim File As String Dim wb1 as

VBA to loop through a folder find a worksheet open it and move all tabs to another workbook

旧城冷巷雨未停 提交于 2020-01-24 13:12:03
问题 I'm working on a project that requires the following: I would like a Macro to loop through a folder and search for a certain worksheet then grab all the tabs from this worksheet and move them to a consolidated workbook Is it possible to find a worksheet based on a certain string in the worksheet name? ex: Financial_data_401kk.xls Could you search by this string "401kk"? Im new to VBA and this is what i have so far Sub ConsolidateSheets() Dim Path as String Dim File As String Dim wb1 as

VBA Copy and Paste Method Not Working

和自甴很熟 提交于 2020-01-24 12:42:31
问题 I am trying to write a simple copy and paste macro and it works up until the last line. When it hits the last line, it says the paste function will not work. I am really confused why this is happening and any help on this would be greatly appreciated. Sheet2.Columns("A:B").Insert Shift:=xlToRight Sheet2.Columns("F:G").Cut Sheet2.Activate Columns("A:B").Select ActiveSheet.Paste Sheets("SourceData").Columns("A:B").Insert Shift:=xlToRight Sheets("SourceData").Activate Columns("A:B").Select

VBA Copy and Paste Method Not Working

只谈情不闲聊 提交于 2020-01-24 12:41:48
问题 I am trying to write a simple copy and paste macro and it works up until the last line. When it hits the last line, it says the paste function will not work. I am really confused why this is happening and any help on this would be greatly appreciated. Sheet2.Columns("A:B").Insert Shift:=xlToRight Sheet2.Columns("F:G").Cut Sheet2.Activate Columns("A:B").Select ActiveSheet.Paste Sheets("SourceData").Columns("A:B").Insert Shift:=xlToRight Sheets("SourceData").Activate Columns("A:B").Select

Align Excel cell to center VB - xlCenter is not declared

爷,独闯天下 提交于 2020-01-24 12:09:33
问题 Im using Visual Studio 2013 Visual Basic, MS ACCESS 2013, EXCEL 2013 My program Save As the data in my datagrid to excel. I use access 2013 as my database Here is my code: Imports System.Data.OleDb Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'AccessdbtestDataSet.country' table. You can move, or remove it, as needed. Me.CountryTableAdapter.Fill(Me