Custom Workbook Property

Apr 6, 2007

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 9 Replies


ADVERTISEMENT

VBA To Create Word File And Add A Custom Property To It

Apr 1, 2009

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 2 Replies View Related

Date Time Picker Custom Format Property?

May 13, 2005

I'm trying to use the Date Time Picker control as a time picker and only want hours and minutes to show. Can this be done with its custom format property (Example)? The usual number formatting string doesn't seem to work.

View 6 Replies View Related

Returning Workbook/sheet Through Property Is Failing

Mar 27, 2007

I made a new class to make other code less redundant, but it isn't functioning. The class has a "workbook" and "worksheet" member, and these can be accessed through properties. The problem is that the properties don't actually seem to return anything, and no data can be accessed through them.

Private mActiveWorkBook As WorkBook
Private mActiveWorkSheet As Worksheet

Property Get wSheet() As Worksheet
wSheet = mActiveWorkSheet
End Property

Property Get wBook() As WorkBook
wBook = mActiveWorkBook
End Property

'Sets active WorkBook
Sub SetActiveWorkBook(ByVal wBook As String)
Set mActiveWorkBook = Workbooks(wBook)
End Sub

'Sets the activeWorksheet in the workbook.
Sub SetActiveWorkSheet(ByVal wSheet As String)
If mActiveWorkBook Is Nothing Then
MsgBox ("Invalid WorkSheet selection - WorkBook not defined")
Return
End If

Set mActiveWorkSheet = mActiveWorkBook.Worksheets(wSheet)
End Sub

This class is used in the macro as such:

Dim uDate As Updater
Set uDate = New Updater

uDate.SetActiveWorkBook ("Book1.xls")
uDate.SetActiveWorkSheet ("TestTab")

'Below Code is not functioning

uDate.wSheet. Range("A1").Value = "foo"
' Expected result - set Cell A1 in sheet testTab = "foo"
' Actual Result - nothing

Dim st As String
st = uDate.wSheet.Range("B5").Value
MsgBox (st)
' Expected results - bring msgBox of values of cell B5, this cell is not empty
' Actual Result - Empty Message box comes up

So - its fairly obvious to me that something is wrong with the properties. The members themselves are not null, I have verified in the debugger that the class members refer to actual sheets/workbooks, but the properties don't like passing anything out and show as "variable not set" in the debugger. How can I get this to work?? It works fine when I do not use the class, like such:

Dim wB As WorkBook
Set wB = Workbooks("Book1.xls")

Dim wS As Worksheet
Set wS = Worksheets("TestTab")

Dim st As String
st = wS.Range("B5").Value
msgBox(st)

But I would like to get the class and properties to work to save clutter elsewhere.

View 6 Replies View Related

Workbook Protection - Unable To Set Visible Property Of Worksheet Class

Dec 26, 2013

I am having problems with some vba codes when I protect my workbook; 'I get an run-time error 1004 Unable to set visible property of the worksheet class'

The code I am trying is:

Sub Stats1_Return_TextBox1_Click()
ActiveSheet.Unprotect "meme"
Application.Goto Worksheets("BCM Database").Range("L15")
Sheets("Stats 1").Visible = False
ActiveSheet.Protect "meme"

End Sub

How to sort this. One more question is there away of protecting you vba code? stop users being able to view or edit them for instance?

View 4 Replies View Related

ComboBox Error "Could Not Get The List Property - Invalid Property Array Index" When Typing Out Of Range

Jun 9, 2006

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 2 Replies View Related

Custom Menus Available To One Workbook

Sep 24, 2008

There was an article in ozgrid new about excel custom toolbars (<<hover over). The article addressed making the custom menu option available in one workbook with Private Sub Worksheet modules as follows

Private Sub Worksheet_Activate()
Application.CommandBars("Worksheet Menu Bar").Controls _
("My Menu").Enabled = True
End Sub

Private Sub Worksheet_Deactivate()
Application.CommandBars("Worksheet Menu Bar").Controls _
("My Menu").Enabled = False
End Sub

How do you get the first module to run apon opening the workbook and the second module to run when you close the workbook.

View 7 Replies View Related

Use Custom Default Workbook

Oct 3, 2006

I have default settings for new workbooks and worksheets including,
zoom=86/Arial 8/, 0.00/ etc.

I set these up using the .xlt file for templates and they work correctly.

However, when I create a new window under the "Window" menu item, it opens the new window with different (Excel Default?) settings.

Can this new window be made to open with my user-defined settings?

View 8 Replies View Related

Tie Custom Toolbar To Workbook

Feb 8, 2008

I have created a macro and would like to use it in other workbooks. Can this be saved to the tool bar for this purpose?

View 2 Replies View Related

Attaching A Custom Toolbar To Workbook

Apr 14, 2009

I have created a workbook and made a custom toolbar to perform the macro functions for the sheets in the workbook. Everything works great for me, but I want to attach the custom toolbar to the workbook so that whenever someone else pulls up the workbook they pull up the custom toolbar too.

I used the tools menu, clicked customize, toolbars, attach, selected the custom toolbar and clicked copy.

No toolbar appears.

I can select View, Toolbars, and select the custom toolbar, then the toolbar appears, but when I close the sheet the toolbar remains.

When someone else opens the sheet, the toolbar appears without any "buttons." It is an empty toolbar.

The help text isn't helping because the instructions for attaching a custom toolbar to a worksheet (tools/customize/toolbars/attach/copy) do not attach the toolbar to the workbook.

View 6 Replies View Related

Run Macro From Custom Defined Workbook

Jun 12, 2014

How can I have a custom defined workbook run a particular macro?

I'm using the Run Application Method:

Application.Run("'Workbook.xls'!Macro")

However the workbook.xls field is static as my program loops through a folder containing various workbooks, opening these workbooks, and running a specific macro housed in their specific module.

Dim MyFile as Object
MyFile = Dir("C:Test")
While MyFile ""

Workbooks.open Filename:="C:Test" & MyFile
Application.Run("'Workbook.xls'!Macro")
MyFile = Dir

How can I define the current active workbook in the run method? Using the custom 'MyFile' in place of the workbook does not work.

Is there a call module method available?

View 3 Replies View Related

Add Custom Menu Upon Opening Workbook

May 12, 2006

I'm trying to load a custom menu in a workbook to avoid having users to load an add in to use the spreadsheet. I'm trying to add this to the "this workbook" tab but I've never done this.

View 3 Replies View Related

Showing Custom Menu In One Workbook

Nov 30, 2007

I have downloaded a custom menu workbook attached. I am wanting to only show the custom menu in one workbook as it appears in all workbooks open at the time.

View 3 Replies View Related

Add Custom Menus To Single Workbook Only

Apr 3, 2008

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 4 Replies View Related

Creating New Workbook Then Giving It A Custom Filename?

May 25, 2012

I am building a macro and am just not figuring out how to do this. I am trying to create a new workbook, then give it a name. Simple right? Well, I have the format for the file name to be "mm-dd-yy Transmittal #.xlsx" but I can't figure out how to make the # part of that equation start as 1 but if the file already exists change it to 2, if that exists, change it to 3, and so on. Here's what I have so far:

Code:
Sub Transmittal()
Dim NewBook As Workbook
Dim MyPath As String

[Code]....

I don't think I'm allowed to do "x + 1" so that is probably where my problem is coming from.

View 9 Replies View Related

Creating Custom Tool Bar For Macros In Workbook

Jan 6, 2013

I want to create a custom tool bar for a work book but when I right click in the unused part of the tool bar area the only options I get are customize Quick access tool bar and customize the ribbon.

View 3 Replies View Related

Custom Toolbars Visible In A Specific Workbook

Dec 30, 2008

I created 3 custom toolbars. I want toolbar A to be visible only in Workbook A.xls, toolbar B to be visible only in Workbook B.xls and toolbar C to be visible only in Workbook C.xls. while Workbooks A,B, and C are open at the same time. I use Workbook A to automatically open Workbooks B and C.

Problem: Since I'm openning the Workbooks automatically it only keeps the Toolbar C visible on all Woksheets.

I included the following code in the This Workbook Object on each Workbook:

For Workbook A:

Private Sub Workbook_Open()

Application.CommandBars("A").Visible = True
Application.CommandBars("B").Visible = False
Application.CommandBars("C").Visible = False

End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)

Application.CommandBars("A").Visible = False
Application.CommandBars("B").Visible = False
Application.CommandBars("C").Visible = False..............................

View 9 Replies View Related

Save Workbook With Custom Toolbar/CommandBar

Jun 2, 2006

I had made a Workbook with my own command Bars, and everthing is ok .. the problem is when i copy it to anthor pc. i have got an error msg. and when i check the code (debug) i've found the problem is with that command bars ( it's missing )
and now the Q is:

how to copy a workbook with it's all add-in's and customised bars ?

View 2 Replies View Related

Custom Menu For 1 Workbook Not Deleting On Deactivate

Jan 20, 2008

The following code for a custom menu is used in a workbook which has two sheets with
embedded charts, two chart sheets and several sheets for calculations
and information

In This Workbook

Private Sub Workbook_Activate() 'Changed Activate to Open
Run "AddMenus"
End Sub

and

Private Sub Workbook_Deactivate() 'Changed Deactivate to Close
Run "DeleteMenu"
End Sub

and

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Run "DeleteMenu"
End Sub

View 9 Replies View Related

Custom Sort / Filter Workbook By Specific Text

Jun 6, 2014

Is there any way to filter/sort a workbook by a specific text. (EX. Unit 17) I have a spread sheet with 40,000 plus rows and in 1 column it has descriptions. I am needing the filter to filter out all occurrences of Unit 17 and Unit 16. They will not always say the something happened to them. EX Repair brakes on Unit 17 or maybe repair tires on Unit 17...

View 3 Replies View Related

How To Open A Workbook When Select Custom Tab In Ribbon Menu

Oct 5, 2012

I am working on building a custom menu and I am looking for the code that would open a specific workbook execute a macro when I select the tab, can this be done????

View 1 Replies View Related

Show Custom Error Message If Opening Workbook Macro Code Fails

May 17, 2008

I cannot figure out how to get my error handler to work, or actually, not work. It seems to work fine when there is an error, but the code still gets read even when there was not an error. Basically, I am trying to open a file, which may or may not be there. When it is not there I want a message to pop up informing the user. However, when the file is there and it opens, the error handler still gives the message box. Any ideas what I am doing wrong?

Private Sub btnOK_Click()
Application. ScreenUpdating = False
Dim LCSfile As String
LCSfile = frmSelectFile.Listbox1.Value
On Error Goto ErrHandler
Workbooks.Open Filename:=sPath & sDate & "" & LCSfile & "QUANT.CSV"
ErrHandler:
MsgBox ("File is not quantitated. Please select another file.")
Application.ScreenUpdating = True

End Sub

View 2 Replies View Related

Excel 2010 :: Can't Save Custom Table Style Format So That It Is Available Next Time When Open Workbook

Jun 10, 2013

I'm a fan of the Excel 2010 table styles, but can't figure one thing out. When I create a table in excel (Ctrl+T), I like to reformat it with a new defined style. When I save the style, I can use it while I'm in that instance of excel, but when I close and reopen excel, the style is gone. How to save the custom formats to they are always available?

View 3 Replies View Related

Specialcells Property Error "Unable To Get The SpecialCells Property Of The Range Class"

Apr 14, 2007

Having problems with trying to get my vba code to access the SpecialCells property. Receiving the following error.... Unable to get the SpecialCells property of the Range class. The section of my code is below that is causing the error. Keeps stopping on the "Selection.SpecialCells(xlsCellTypeVisible).Select" line.

Sheets(" Book Query").Range("A6:I6").Select
Sheets("Book Query").Range(Selection, Selection.End(xlDown)).Select
Selection.SpecialCells(xlsCellTypeVisible).Select
Selection.Copy
Sheets("Inventories and Variances").Select
Sheets("Inventories and Variances").Range("A7").Select

View 2 Replies View Related

How To Make A Custom Conversion Program / Formula Between Custom Data

Feb 15, 2014

I'm trying to make a converter between about 8 various types of values. These are not units like Km or miles or something like that, but rather numbers that represent a specific "hardness value" on a variety of scales (to name a few: HRC, HRA, K)

What I've been doing so far is plotting the two types against eachother and then getting the best trendline I can so that I can use that formula to convert between the two with relative certainty. (for example, when plotting HV vs HRC my fourth order polynomial trendline with an Rsquared of 1 is y=0.0001x4 - 0.0188x3 + 1.0768x2 - 20.709x + 350.69)

My questions comes up where I was hoping to make a window or box of some sort allowing the user to input a numeric value, then selecting the Input units and the hopeful output calculated units, and have the box spit back to the user the conversion.

View 9 Replies View Related

Custom Transferable Toolbar Of Custom Functions

Sep 2, 2008

I want to be able to create a range of VBA userforms to quickly perform long tedious tasks. I want these userforms to be accessed from a nice tidy toolbar.

I have done this and it looks nice and works well. What I would like to be able to do is have my custom toolbar of userform controlled functions be transferable so that if someone else wants my toolbar and attached functions they can install it easily much the same way you can do with an add in.

Is this sort of thing possible or does it require them to manually install all my userforms, modules and toolbar? If it is possible what sort of things should I be looking at?

View 9 Replies View Related

Cannot Set Listindex Property!

Nov 5, 2008

For some reason my selection won't return to where it's supposed to in a listbox after I've increased it's column widths. It's very strange.

I've put together an example of the issue as the actual workbook is enormous, but the demonstration seems to work.

I've tried exporting the Listindex resetting code to an external function, but it didn't help either.

Can anyone understand this behaviour?

View 6 Replies View Related

Using Destination Property

May 14, 2009

I would like to Copy the cell value from A1 into the next available empty cell in a column (in this case sheet2 A) so that I can create a list of values from A1 over time and graph it.

View 6 Replies View Related

LineStyle Property

May 4, 2008

Sub test()
With Worksheets("BUDGET")
.Range("E10").EntireRow.WrapText = True
With .Range("B10").CurrentRegion
With Intersect(Worksheets("BUDGET").Rows("10:" & Rows.Count), .Cells).Borders
.LineStyle = xlSolid
.Weight = 1
End With
End With
End With
End Sub
This code works fine on my Laptop (2007). On Desktop (2003), gives error: Unable to set the LineStyle property of the Borders class

.LineStyle = xlSolid highlited

I have tried this (on both computers) in a larger procedure(where it should be) and in a Module of it's own. Same results.

View 9 Replies View Related

FoundFiles Property

May 10, 2006

i was searching in VBA help & found this example:

a macro that steps through the list of files found during a search and displays the path for each file.

With Application.FileSearch
For i = 1 To .FoundFiles.Count
MsgBox .FoundFiles(i)
Next I
End With

how can i modify this macro so that it displays only
the file name not the full path
for example instead of displaying
"C:Documents and SettingsDesktopMainstatment1.txt"
i want it to display
"statment1.txt"

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved