VBA To Create Word File And Add A Custom Property To It
I have an Excel sheet with a long list of data. A short example is shown below:
Section | Title | Item
1 | INTRODUCTION | a
1.1 | title2 | b
1.2 | title3 | c
1.2.1 | title4 | d
1.2.2 | title5 | e
I made a VBA macro in Excel that runs through this list and creates a new Word file for each item. The filename of the document is based on the data in the Excel file (section and title). Now I would like to add a custom property to each of the newly created Word files, i.e. the value in the 'item' column. Does anyone of you know how I should do this? Or should it be better if I write a macro in Word that runs through the Excel data to create the word files? Here is the code I use to generate the word files:
View Complete Thread with Replies
Sponsored Links:
Related Forum Messages:
Create Custom Menu Items For Add-in
I have created an Addin from one I found on this site which creates a menu on the CommandBar. On this menu I can add my Macros. The Menu is initially supposed to perform a delete function then an add, just in case the menu already exists on the CommandBar. It is also supposed to Uninstall the menu when you de-select the Addin. At the moment it doesn't seem to be doing either, as I have now got 5 CommandBar menu's all the same and I can't delete them? This also creates a problem of when I add another macro, the menu on the CommandBar doesn't update with the addition? I have attached the .xla file for you to look at and see where I'm going wrong. VBA Macros & Creating An Add-in For Them
View Replies!
View Related
Custom Macro To Create New File From Data
I'm looking to create a new file from data in my table. I don't want to even imagine having to do this manually again...I'm optimistic there is a solution. All the data needed to create the file is in the table, but i need it stacked and organized in a weird way. It's almost to hard to explain...so I color coded an attachement that basically says it all. It's pretty much the same thing repeated over and over except the last 2 lines. It's just a really messed up organization. In the real version I need the new file in a new workbook. I'm extremely grateful to anyone who can automate this thing
View Replies!
View Related
Create Custom Menus For Specific File
I tried to create a custom menu for a specific file. However, after creating the menu, I posted the file in Sharepoint. When a user download the file from the sharepoint site, the custom menu doesn't work because it is looking for the macro links from my computer. Another problem is that now the custom menu shows up in all other excel files that I open. My questions are: 1. How do I do it so that the custom menu shows up only when this file is opened up. 2. How do I go about making the menu to look for the macros embeded in the file itself instead of looking for it in my file folder.
View Replies!
View Related
Add Custom Sort List To VBA Code
I have a Macro that I have recorded that autosorts several columns for me. This works fine as I have 5 columns that need to be sorted in a particular way. The problem is that I have a custom list which I stored using the: Tools>Options>Custom List tab. Now this works fine on my pc as I have the custom list stored on my PC.however the problem is when someone else uses it on their PC it may no longer work as they won't have my custom list stored on their PCs. Is there a way to store the custom list in a Macro and then use that list to sort to the criteria needed. For example "One, Two, Three, Four" will not store in alphabetically, so hope would I be able to sort so that they would appear in a chronological manner? Below is the code for the Macro I recorded. As you can see one of the lines says "OrderCustom:=6"; this I am assuming is reading from the list I created.
View Replies!
View Related
To Link File In Word Via Vba
What is the script in order for me to link a MS Word file to excel. What I intend to do is to customise the commandbutton, so that once a user click on it, the linked MS Word file (stored in the local drive) will pop-up and he/she can do the necessary amendments to the file?
View Replies!
View Related
Custom Workbook Property
I`m building a macro for which I would like to save a parameter for the macro to read and set. I would like this parameter to be saved (permanently) in something like a custom workbook property, i.e. Tarabo (=Yes/No). How can I create/read/wright using vba code?
View Replies!
View Related
VBA To Add Multiple Tables To End Of Word Document
I have an Excel spreadsheet of data that I would like to export into tables in a new word document. The code below (without the marked section) does this, but I can’t figure out how to create a second table after the first one. Eventually I will use a For…Next loop to do this many times, but I’m trying to make the problem smaller by just making a second table. Sub CreateNewWordDoc() ' add a reference to the Word-library Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Dim wrdTable As Word.Table Dim xText Set wrdApp = CreateObject("Word.Application") Set wrdDoc = wrdApp.Documents.Add ' create a new document Set wrdRange = wrdDoc.Range wrdApp.Visible = True.........
View Replies!
View Related
Vba To Create A New File From Spreadsheet
I have the following spreadsheet: A-------------B File No.-----PRODUCT TYPE 123456-----NDT 123456-----NDT 123456-----NDT 123456--------- 123456--------- 789110--------- 789110--------- 789110--------- What I need is if there is an NDT in Column B and 123456 in Column A then I need to eliminate all rows which contain 123456. End result A 789110 789110 789110
View Replies!
View Related
Range Text Property To Add String To Cell
I don't understand what I am missing. but I can't paste a string into a cell [range.cells(x,y).text = string] Here is my ' ' -delete any rows that contain "Fab 11" ' -rename any cell that has "Supply x" (Delete " supply x" from text) Dim cellText As String Dim i As Integer Dim lastRow As Long Dim rngSigac As Range Dim wb As Workbook Dim ws As Worksheet
View Replies!
View Related
Save File With Hidden Property
I have an excel file which is in windows explorer has its property set to hidden. I have another excel file, with some Vba in it, which opens the hidden file, inserts some data into it, saves the file and closes it. ActiveWorkbook.Save ActiveWorkbook.Close This all works, except that the hidden property is lost in the process. Is there a way of saving the file, and keeping the hidden property? This is just so that users cant see the file and accidently open it.
View Replies!
View Related
Output Property To Save As File
I'm trying to display some result in my sheet and I don't go further of the MsgBOx use. see my vba code Dim xslt As New MSXML2.XSLTemplate40 Dim xslDoc As New MSXML2.FreeThreadedDOMDocument40 Dim xmlDoc As New MSXML2.DOMDocument40 Dim xslProc As IXSLProcessor Dim paramxml As MSXML2.DOMDocument40 xslDoc.async = False xslDoc.Load "c:compara.xsl" If (xslDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xslDoc.parseError MsgBox ("Ha um erro " & myErr.reason) Else Set xslt.stylesheet = xslDoc xmlDoc.async = False xmlDoc.Load "C:Instructional_program.xml".................
View Replies!
View Related
Create Custom Menus
I was reviewing the "Create Custom Menu Items in Excel VBA" code located at [url] and cannot figure out something. How do I add a menu dropdown that contains MORE than one submenu item? This is the code my question pertains to: ...
View Replies!
View Related
To Create Custom Msgbox Choices
I am trying to create a msgprompt but instead of using the default yes or no, I need 3 options, so if the user clicks the first option, it will check a certain box. It will look like this. "What envelopes do we use? Choice 1. Branded Choice 2. Unbranded Choice 3. Client Branded
View Replies!
View Related
Create A Custom Sort Order
I am trying to create custom sort list. It works below when I define range as A1:A79. Sub SortWS2() Dim SortOrder As Variant Dim sheetsorder As Range Dim Ndx As Long Application. ScreenUpdating = False With Worksheets("Sort Order").Range("A1:A79") For Ndx = .Cells.Count To 1 Step -1 Worksheets(.Cells(Ndx).Value).Move before:=Worksheets(1) Next Ndx End With Application.ScreenUpdating = True End Sub I have created a dynamic range called sheetsorder. If I revise my code it does not work. Sub SortWS2()................
View Replies!
View Related
Create Custom Serialized Date Format
I am needing to create a sequential serial number using a format yyyy-nnn, where yyyy is the current year and nnn is a sequential number (2007-001). I've tried using both a formula and custom formats but cannot get the cell contents to display as desired. I've used TODAY()&"-"&"001", which gives a valid result of 39100-001, but this not what I need. I've tried many other combinations in the custom option for formatting the cell.
View Replies!
View Related
Custom Add In
I added a custom add in ages and ages ago and have forgotten how I did it! I'm now trying to remove it but not having much luck. Its not listed in the Tools>References menu and its not added on to a workbook saved in the C:Documents and SettingsUserApplication DataMicrosoftExcelXLSTART folder. Are there other ways I could have added it? If so can someone let me know as I might be able to remove it then!
View Replies!
View Related
Create Hyperlink From 2 Cells, Then Open Word
The purpose of this endeavour is to create a cell that when the user clicks on it, it will open up a Word file that THAT particular cell represents. FIRST STEP: Take the values from Column D (Tract Number), then add a ".doc" extension to it, then put the UNC filepath (\serverdata eports) in front of all of that and put it in Column E. See me example below: File path plus Tract Number plus Extension \serverdata eports 7-5-065-085 .doc .... to generate something like this: \serverdata eports7-5-065-085.doc SECOND STEP: Use the value (only when the user clicks on the hyperlink) from the cell in Column E and start up Word.
View Replies!
View Related
Create List Based On Word Chosen
If a specific word is entered in a cell I want a list to show in another cell. This is better explained in an example. In cell A2 I have a validation list of names, eg. Mary, Mary Birth, John, John Birth,. . .) In cell N2 I have another validation list of places , eg. Ireland, England, Wales, USA, Scotland, . . ) In A2 if a name with Birth is chosen then I only want them to be able to choose from Ireland or England.
View Replies!
View Related
Custom Context Menus For Any WB (using Add-in?)
Ok, so I have this neat little macro that on right-click brings up a custom context menu that displays a few different options - for example one such function is simply copying the selected cell content to a (specific) different sheet. It is a very useful feature in the context I am normally using it to merge information from different locations in a new structure (well, I think this is irrelevant, but just letting you know basically what I am doing). Anyhow, to implement the custom context menu, I am using events in the ThisWorkbook object, namely Activate to add context menu entries and DeActivate to remove them if switching workbook. Now, if I receive any workbook from someone else, I'd like to add this feature to get the custom context menu easily without having to copy the received workbook into a new workbook (it's a bit of a hassle, and ideally, if the received workbook has any other macros, this function could just be merged). I was thinking using an add-in to achieve this, but using the ThisWorkbook events in the add-in doesn't trigger the events (I guess because the hidden workbook in the add-in is never "Activated" or "DeActivated").
View Replies!
View Related
Verify Existence Of A Custom Add-in
if there's a way I can verify that a custom add-in is active? My company uses an add-in to allow end users to construct several types of API calls. My program depends on that add-in to be installed. I'd like to try to detect the add-in and halt the program if it's not there.
View Replies!
View Related
Load Custom Functions In An Add-in
I have created some user defined functions and have associated them to a custom category. To simplify things, I wanted to add these functions and the custom category macro to an Addin I already have installed for all my employees. How do I get the the custom category macro to excecute? It should run as soon as excel is opened...but I am not sure what event should be used and where is it installed?
View Replies!
View Related
Add List As A Subchoice To A Custom Menu
I have create a custom menu and want to add a choice and a subchoice that will guide the user to insert a number in an inputbox or under a list. Then the user's selected number it will be used as parameter for a vba code. Eg.: The choice is: How many rows will be marked The subchoice : 10 (default value) What i want is the following: If the user choose the above subchoice then it has to be appeared an inputbox or something like that in which he has to insert a number, eg. 45. After that the choice must shows The choice: How many rows will be marked The subchoice: 45 This parameter must be active all the time that the user uses the workbook. At the end, if the user saves the workbook, the next time it will be opened, the subchoice must have the value 45. Look at the attachment image to see exactly what i want Here's the code. Just copy it under a module Option Explicit Dim cbMenu As CommandBarControl Dim cbSubMenu As CommandBarControl Public MenuSeries
View Replies!
View Related
Custom Function Preceded With Add-in Path
I have created an addin (myAddin.xla) with custom functions in it. In a given cell, my funtion would look something like "=myCustomFunction(A1, B5)". Periodically, while I'm working with the spreadsheet, I'll do something to a cell and the formulas in all the cells which used a custom function immediately get reset to something along the lines of "=C:...Application DataMicrosoftAddInsmyAddin.xla'!myCustomFunction(A1, B5)". The reset function also causes the function not to work properly and I get a "#NAME?" error in the cell. I haven't yet figured out what sequence of actions causes the reset (it happens infrequently, but often enough to be a major problem) but it happens while I'm working with the document (i.e., it doesn't seem to be linked to saving/closing/reopening/etc). After I notice the reset, if I go to each cell that uses a custom function and delete everything from "C:... to myAddin.xla!" in the formula bar and hit enter, the function works normally as before. (Technically, my Windows XP Pro system uses synchronization with a server at work, so the file path is not "C:...Application DataMicrosoftAddInsmyAddin.xla'!" but rather "\myServerNamemyDirectoryDocuments and SettingsmyUserNameApplicationDataMicrosoftAddInsmyAddin.xla'!". I'm not sure if this reset error has anything to do with being connected to the server or not, but figured I'd mention it anyway.)
View Replies!
View Related
Add Custom Menus To Single Workbook Only
Using example code from Adding Custom Menus, I now have functional menu items that call my macros appropriately. The example also contains code to add or remove a menu conditional on its window being active. What I need is a slight variant on this but not quite obvious to my novice brain. The add and remove menu code is now stored in my personal.xls file. However, I need that the condition check that a key string be present in the name of the active window, not the file where the macro is stored. Thus, if the front window is of the file named MyData, then the special menus get added (the conditional string is "MyData"). If the window is named YourData, the special menus get removed. Note, neither of these two files contain any macros.
View Replies!
View Related
Add Custom Menu Item / Toolbar
Trying to write a VBA code to add a new menu item with submenus on the Standard toolbar when Workbook_Open and then deleting it (_Before close). Just having trouble with the creating of the menu item. Here is what I have so far: Sub Workbook_Open() ... Dim menuitem As CommandBarPopup Set Menu = Application.CommandBars("Menu Item").Controls.Add (Type:=msoControlPopup, Before:=13) ... End Sub
View Replies!
View Related
Embed Add-in In A Word Document
I've just written up an SOP for a reconciliation process. Part of it requires the reader to use some Excel UDFs that I've created. Rather than having someone look for the UDF file on the network, I tried to embed it as an Excel Worksheet Icon within my procedure document. However, when I double-click the icon to launch the add-in, I get the following error message: "Microsoft Word can't start the application required to open this object. An error occurred and this feature is no longer functioning properly. Would you like to repair this feature now?" This does not happen when I embed a regular Excel workbook, or even a template.
View Replies!
View Related
Add Custom Menu At Specific Location On Toolbar
I would like to use the attached "menu maker" file I found on Ron De Bruin's site using a Sheet to build the menu, yet be able to place it before the Help menu as suggested by this site [url] by finding the position of Help. I have amended the code yet receive a "Compile error: Variable not defined" error.
View Replies!
View Related
Creating A Custom Button When I Install My Self-made Add-in
Finally after 3 days of intensive studying VBA, my first add-in pack is ready to be installed in the office. I've got my custom form all ready, now all I need is to have excel create a custom button on the toolbar that calls up my custom form when clicked. The idea of assigning a shortcut key doesn't really appeal to me. I'll be packaging it up in .xla format. Would be greatful if anyone can direct me on how to add a button to call up my form (only one form in fact).
View Replies!
View Related
Saving Custom Toolbar With File
The file who containd the toolbars informations is C:Documents and Settings<<USER>>Application DataMicrosoftExcelExcel.xlb I copied this file to another computer and my custom toolbar appeared there. In a file, I created a custom toolbar with submenus. It is possible to save this toolbar with file, so that I can use the file on other computers without the need to create each time this bar.
View Replies!
View Related
Opening Word & Count Word Instances In A Word Document
I have an excel program that is supposed to count word instances in a word document. I can't seem to find the right declaration for a word document. For example to declare a workbook in excel its Dim wb As Work Book I've tried Dim doc As Word.Document 'or Dim doc As Word.Application as shown in some of the forum posts, but an error user-type not defined keeps displaying.
View Replies!
View Related
Sample Code To Add/delete Custom Menu Items
Option Explicit Dim cMenu1 As CommandBarControl Dim cbMainMenuBar As CommandBar Dim iHelpMenu As Integer Dim cbcCustomMenu As CommandBarControl '(2) Set cbMainMenuBar = Application.CommandBars("Worksheet Menu Bar") '(4) Set cbcCustomMenu = cbMainMenuBar.Controls.Add(Type:=msoControlPopup) '(5) Give the control a caption................ I have created several spreadsheet with customized menus. In step 5 when I type a period the options for selecting Caption does not appear. In step 6 the 'Control' word didn't appear in list. Sometimes the options in step 6 do appear BUT not the option for Controls. I have created spreadsheets with menus that work but the only way I could do it was to cut and paste from the website and then modify it.
View Replies!
View Related
Add/Remove Custom Control To Chart Drop-Down Menu
I want to add a control under Chart on the menu bar. This line of code errors with "Invalid Procedure Call or Argument" With Application. CommandBars("Worksheet menu bar").Controls("Chart") Change "Chart" to "File" or "Edit" or "Tools" and it's fine. The Chart item only appears when a chart is selected, but it errors even when a chart on the worksheet is selected.
View Replies!
View Related
ComboBox Error "Could Not Get The List Property - Invalid Property Array Index" When Typing Out Of Range
I have a form with several combo boxes, and they function just the way I like as far as being able to pick from the list, or typing in them and having it show you the next available item in the list as you add letters. Whats happening that I would like to know how to deal with is... as soon as you type a letter that is not in my lookup range it generates an error. "Could not get the list property - Invalid property array index". I don't want people to be able to add to the list, but I would like a msgbox to pop up. Then allow them to go back to the box and try again.
View Replies!
View Related
Open Word File
I would like to open a word file in my Excel VBA code. The word document has its own VBA code that will run when Excel opens it. I do not need to move any data around I just want Excel to open my word doc.
View Replies!
View Related
Deleting Characters From A Word File
I'm trying to automate a redundant task. I have several Word files in one central folder. I need to open each file, remove all paragraph marks (via find/replace all), copy the result, and paste it into an Excel sheet. This process will be repeated for each file in the folder. The code I have is almost there, however, I can't get it to do the find/replace. Below is an extract of my code for the Word application part. The code for the copy and paste will be inserted after the replace action works: Dim Wapp As Object Dim i As Integer WorksheetsLocation = TextBox1.Value ' this is the folder location brought in from an input box On Error Resume Next Set wApp = GetObject(, "Word.Application") If Err.Number 0 Then 'Word isn't already running Set wApp = CreateObject("Word.Application") End If On Error GoTo 0
View Replies!
View Related
Insert A Picture In The Word File?
I had copied a macro from this forum [it was posted by either shg or NBVC], and I modified it to fit my needs. The macro creates a new word document and sends a series of cells from an excel worksheet column to this word file. Everything works fine, but now I need to insert a picture after row 14. I have inserted the code [colored red], but I am sure the syntax or something isn't right. That part doesn't work.
View Replies!
View Related
|