Search Results

Search found 1188 results on 48 pages for 'vba'.

Page 20/48 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • How to generate XML from an Excel VBA macro?

    - by SuperNES
    So, I've got a bunch of content that was delivered to us in the form of Excel spreadsheets. I need to take that content and push it into another system. The other system takes its input from an XML file. I could do all of this by hand (and trust me, management has no problem making me do that!), but I'm hoping there's an easy way to write an Excel macro that would generate the XML I need instead. This seems like a better solution to me, as this is a job that will need to be repeated regularly (we'll be getting a LOT of content in Excel sheets) and it just makes sense to have a batch tool that does it for us. However, I've never experimented with generating XML from Excel spreadsheets before. I have a little VBA knowledge but I'm a newbie to XML. I guess my problem in Googling this is that I don't even know what to Google for. Can anyone give me a little direction to get me started? Does my idea sound like the right way to approach this problem, or am I overlooking something obvious? Thanks StackOverflow!

    Read the article

  • Interacting with IE using sendkeys from Excel

    - by Thomas Egan
    I'm trying to write an application which uses values from excel and then switches to a web application using sendkeys. The problem I am having is that I cannot used sendkeys ("{ENTER}") or sendkeys ("^o") as I don't have the access for that. I'm trying to automate a very trivial admin task. I've thought about using the mouse to interact with the links as well as pausing and waiting for the user to just hit return but so far have been unable to come up with a solution. Do you think there is anyway around this? I have some VBA knowledge (enough to get me this far) but not a great deal.

    Read the article

  • EXCEL VBA STUDENTS DATABASE [on hold]

    - by BENTET
    I AM DEVELOPING AN EXCEL DATABASE TO RECORD STUDENTS DETAILS. THE HEADINGS OF THE TABLE ARE DATE,YEAR, PAYMENT SLIP NO.,STUDENT NUMBER,NAME,FEES,AMOUNT PAID, BALANCE AND PREVIOUS BALANCE. I HAVE BEEN ABLE TO PUT UP SOME CODE WHICH IS WORKING, BUT THERE ARE SOME SETBACKS THAT I WANT TO BE ADDRESSED.I ACTUALLY DEVELOPED A USERFORM FOR EACH PROGRAMME OF THE INSTITUTION AND ASSIGNED EACH TO A SPECIFIC SHEET BUT WHENEVER I ADD A RECORD, IT DOES NOT GO TO THE ASSIGNED SHEET BUT GOES TO THE ACTIVE SHEET.ALSO I WANT TO HIDE ALL SHEETS AND BE WORKING ONLY ON THE USERFORMS WHEN THE WORKBOOK IS OPENED.ONE PROBLEM AM ALSO FACING IS THE UPDATE CODE.WHENEVER I UPDATE A RECORD ON A SPECIFIC ROW, IT RATHER EDIT THE RECORD ON THE FIRST ROW NOT THE RECORD EDITED.THIS IS THE CODE I HAVE BUILT SO FAR.I AM VIRTUALLY A NOVICE IN PROGRAMMING. Private Sub cmdAdd_Click() Dim lastrow As Long lastrow = Sheets("Sheet4").Range("A" & Rows.Count).End(xlUp).Row Cells(lastrow + 1, "A").Value = txtDate.Text Cells(lastrow + 1, "B").Value = ComBox1.Text Cells(lastrow + 1, "C").Value = txtSlipNo.Text Cells(lastrow + 1, "D").Value = txtStudentNum.Text Cells(lastrow + 1, "E").Value = txtName.Text Cells(lastrow + 1, "F").Value = txtFees.Text Cells(lastrow + 1, "G").Value = txtAmountPaid.Text txtDate.Text = "" ComBox1.Text = "" txtSlipNo.Text = "" txtStudentNum.Text = "" txtName.Text = "" txtFees.Text = "" txtAmountPaid.Text = "" End Sub Private Sub cmdClear_Click() txtDate.Text = "" ComBox1.Text = "" txtSlipNo.Text = "" txtStudentNum.Text = "" txtName.Text = "" txtFees.Text = "" txtAmountPaid.Text = "" txtBalance.Text = "" End Sub Private Sub cmdClearD_Click() txtDate.Text = "" ComBox1.Text = "" txtSlipNo.Text = "" txtStudentNum.Text = "" txtName.Text = "" txtFees.Text = "" txtAmountPaid.Text = "" txtBalance.Text = "" End Sub Private Sub cmdClose_Click() Unload Me End Sub Private Sub cmdDelete_Click() 'declare the variables Dim findvalue As Range Dim cDelete As VbMsgBoxResult 'check for values If txtStudentNum.Value = "" Or txtName.Value = "" Or txtDate.Text = "" Or ComBox1.Text = "" Or txtSlipNo.Text = "" Or txtFees.Text = "" Or txtAmountPaid.Text = "" Or txtBalance.Text = "" Then MsgBox "There is not data to delete" Exit Sub End If 'give the user a chance to change their mind cDelete = MsgBox("Are you sure that you want to delete this student", vbYesNo + vbDefaultButton2, "Are you sure????") If cDelete = vbYes Then 'delete the row Set findvalue = Sheet4.Range("D:D").Find(What:=txtStudentNum, LookIn:=xlValues) findvalue.EntireRow.Delete End If 'clear the controls txtDate.Text = "" ComBox1.Text = "" txtSlipNo.Text = "" txtStudentNum.Text = "" txtName.Text = "" 'txtFees.Text = "" txtAmountPaid.Text = "" txtBalance.Text = "" End Sub Private Sub cmdSearch_Click() Dim lastrow As Long Dim currentrow As Long Dim studentnum As String lastrow = Sheets("Sheet4").Range("A" & Rows.Count).End(xlUp).Row studentnum = txtStudentNum.Text For currentrow = 2 To lastrow If Cells(currentrow, 4).Text = studentnum Then txtDate.Text = Cells(currentrow, 1) ComBox1.Text = Cells(currentrow, 2) txtSlipNo.Text = Cells(currentrow, 3) txtStudentNum.Text = Cells(currentrow, 4).Text txtName.Text = Cells(currentrow, 5) txtFees.Text = Cells(currentrow, 6) txtAmountPaid.Text = Cells(currentrow, 7) txtBalance.Text = Cells(currentrow, 8) End If Next currentrow txtStudentNum.SetFocus End Sub Private Sub cmdSearchName_Click() Dim lastrow As Long Dim currentrow As Long Dim studentname As String lastrow = Sheets("Sheet4").Range("A" & Rows.Count).End(xlUp).Row studentname = txtName.Text For currentrow = 2 To lastrow If Cells(currentrow, 5).Text = studentname Then txtDate.Text = Cells(currentrow, 1) ComBox1.Text = Cells(currentrow, 2) txtSlipNo.Text = Cells(currentrow, 3) txtStudentNum.Text = Cells(currentrow, 4) txtName.Text = Cells(currentrow, 5).Text txtFees.Text = Cells(currentrow, 6) txtAmountPaid.Text = Cells(currentrow, 7) txtBalance.Text = Cells(currentrow, 8) End If Next currentrow txtName.SetFocus End Sub Private Sub cmdUpdate_Click() Dim tdate As String Dim tlevel As String Dim tslipno As String Dim tstudentnum As String Dim tname As String Dim tfees As String Dim tamountpaid As String Dim currentrow As Long Dim lastrow As Long 'If Cells(currentrow, 5).Text = studentname Then 'txtDate.Text = Cells(currentrow, 1) lastrow = Sheets("Sheet4").Range("A" & Columns.Count).End(xlUp).Offset(0, 1).Column For currentrow = 2 To lastrow tdate = txtDate.Text Cells(currentrow, 1).Value = tdate txtDate.Text = Cells(currentrow, 1) tlevel = ComBox1.Text Cells(currentrow, 2).Value = tlevel ComBox1.Text = Cells(currentrow, 2) tslipno = txtSlipNo.Text Cells(currentrow, 3).Value = tslipno txtSlipNo = Cells(currentrow, 3) tstudentnum = txtStudentNum.Text Cells(currentrow, 4).Value = tstudentnum txtStudentNum.Text = Cells(currentrow, 4) tname = txtName.Text Cells(currentrow, 5).Value = tname txtName.Text = Cells(currentrow, 5) tfees = txtFees.Text Cells(currentrow, 6).Value = tfees txtFees.Text = Cells(currentrow, 6) tamountpaid = txtAmountPaid.Text Cells(currentrow, 7).Value = tamountpaid txtAmountPaid.Text = Cells(currentrow, 7) Next currentrow txtDate.SetFocus ComBox1.SetFocus txtSlipNo.SetFocus txtStudentNum.SetFocus txtName.SetFocus txtFees.SetFocus txtAmountPaid.SetFocus txtBalance.SetFocus End Sub PLEASE I WAS THINKING IF I CAN DEVELOP SOMETHING THAT WILL USE ONLY ONE USERFORM TO SEND DATA TO DIFFERENT SHEETS IN THE WORKBOOK.

    Read the article

  • Aggregating Excel cell contents that match a label [migrated]

    - by Josh
    I'm sure this isn't a terribly difficult thing, but it's not the type of question that easily lends itself to internet searches. I've been assigned a project for work involving a complex spreadsheet. I've done the usual =SUM and other basic Excel formulas, and I've got enough coding background that I'm able to at least fudge my way through VBA, but I'm not certain how to proceed with one part of the task. Simple version: On Sheet 1 I have a list of people (one on each row, person's name in column A), on sheet 2 I have a list of groups (one on each row, group name in column A). Each name in Sheet 1 has its own row, and I have a "Data Validation" dropdown menu where you choose the group each person belongs to. That dropdown is sourced from Sheet 2, where each group has a row. So essentially the data validation source for Sheet 1's "Group" column is just "=Sheet2!$a1:a100" or whatever. The problem is this: I want each group row in Sheet 2 to have a formula which results in a list of all the users which have been assigned to that group on Sheet 1. What I mean is something the equivalent of "select * from PeopleTab where GROUP = ThisGroup". The resulting cell would just stick the names together like "Bob Smith, Joe Jones, Sally Sanderson" I've been Googling for hours but I can't think of a way to phrase my search query to get the results I want. Here's an example of desired result (Dash-delimited. Can't find a way to make it look nice, table tags don't seem to work here): (Sheet 1) Bob Smith - Group 1 (selected from dropdown) Joe Jones - Group 2 (selected from dropdown) Sally Sanderson - Group 1 (selected from dropdown) (Sheet 2) Group 1 - Bob Smith, Sally Sanderson (result of formula) Group 2 - Joe Jones (result of formula) What formula (or even what function) do I use on that second column of sheet 2 to make a flat list out of the members of that group?

    Read the article

  • What would an Outlook 2007 macro to automate Paste Special - Unformatted Text look like?

    - by Gary Petersen
    I'd like to assign a macro in Outlook 2007 to a Toolbar button that would execute the equivalent of these clicks when there is formatted text in the Windows clipboard: Click the Paste icon by the bottom arrow Click the Paste Special link. Click the Unformatted Text link. I have similar macros in Excel 2007 and Word 2007 but haven't been able to get one to work in Outlook 2007 / VBA. What would the VBA code for such a macro be?

    Read the article

  • Help to bypass password for sample projects of excel.

    - by Munna
    Hello Friend.. I am doing project in EXCEL VBA. i am taking refernce of some projects made in excel vba. But when I trid to open that excel sample projects, it ask me for password. so how can bypass password for that excel project so i can take refrence so that i can take refrence of sample. Please help....

    Read the article

  • I am trying to use VBA code to save inkpicture contents, can only use vb.net or C#

    - by zaphod23
    I found this code that is missing the funtion call in thelast line, any ideas on what the save to file command would be?, I'll just kludge it in. 'CODE to SAVE InkPicture to FILE Dim objInk As MSINKAUTLib.InkPicture Dim bytArr() As Byte Dim File1 As String File1 = "C:\" & TrainerSig & ".gif" Set objInk = Me.InkPicture2.Object If objInk.Ink.Strokes.Count > 0 Then bytArr = objInk.Ink.Save(2) fSaveFile bytArr, File1 End If

    Read the article

  • The host 'smtp' could not be found.

    - by SmartestVEGA
    I am getting the following error while sending mail by click of a button in MS access form I am using sendObject to send mail using vba code. The host 'smtp' could not be found. Please verify that you have entered the server name correctly. Account: 'pop3', Server: 'smtp', Protocol: SMTP, Port: 25, Secure(SSL): No, Socket Error: 11001, Error Number: 0x800CCC0D Points to note: I am able to send and receive mails in my outlook; Problem is only when send mails through VBA access application.(Means it is not a outlook client configuration problem) When i copy paste the Vba application to another PC, i could successfully send emails without any error. (means this is not a vba access application problem) Please help.

    Read the article

  • Why does VBA Find loop fail when called from Evaluate?

    - by Abiel
    I am having some problems running a find loop inside of a subroutine when the routine is called using the Application.Evaluate or ActiveSheet.Evaluate method. For example, in the code below, I define a subroutine FindSub() which searches the sheet for a string "xxx". The routine CallSub() calls the FindSub() routine using both a standard Call statement and Evaluate. When I run Call FindSub, everything will work as expected: each matching address gets printed out to the immediate window and we get a final message "Finished up" when the code is done. However, when I do Application.Evaluate "FindSub()", only the address of the first match gets printed out, and we never reach the "Finished up" message. In other words, an error is encountered after the Cells.FindNext line as the loop tries to evaluate whether it should continue, and program execution stops without any runtime error being printed. I would expect both Call FindSub and Application.Evaluate "FindSub()" to yield the same results in this case. Can someone explain why they do not, and if possible, a way to fix this? Thanks. Note: In this example I obviously do not need to use Evaluate. This version is simplified to just focus on the particular problem I am having in a more complex situation. Sub CallSub() Call FindSub Application.Evaluate "FindSub()" End Sub Sub FindSub() Dim rngFoundCell As Range Dim rngFirstCell As Range Set rngFoundCell = Cells.Find(What:="xxx", after:=ActiveCell, LookIn:=xlValues, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False) If Not rngFoundCell Is Nothing Then Set rngFirstCell = rngFoundCell Do Debug.Print rngFoundCell.Address Set rngFoundCell = Cells.FindNext(after:=rngFoundCell) Loop Until (rngFoundCell Is Nothing) Or (rngFoundCell.Address = rngFirstCell.Address) End If Debug.Print "Finished up" End Sub

    Read the article

  • VBA: How go I get the total width from all controls in an Access form?

    - by Stefan Åstrand
    Hi, This is probably very basic stuff, but please bear in mind I am completely new to these things. I am working on a procedure for my Access datasheet forms that will: Adjust the width of each column to fit content Sum the total width of all columns and subtract it from the size of the window's width Adjust the width of one of the columns to fit the remaining space This is the code that adjusts the width of each column to fit content (which works fine): Dim Ctrl As Control Dim Path As String Dim ClmWidth As Integer 'Adjust column width to fit content For Each Ctrl In Me.Controls If TypeOf Ctrl Is TextBox Then Path = Ctrl.Name Me(Path).ColumnWidth = -2 End If Next Ctrl How should I write the code so I get the total width of all columns? Thanks a lot! Stefan

    Read the article

  • Using Excel VBA to send emails. Problem with attachments becoming embedded by accident.

    - by Alexei
    Hi, I am having an issue with an Excel macro I wrote that is used by several users within my company. It is used to send numerous emails daily with attachments that are also Excel workbooks. The issue is that sometimes, instead of the file simply being attached as it should be, it becomes an embedded object. This embedded object is openable by users on the email within the company (after clicking through the "YOu are about to activate an embedded object that may contain viruses or be otherwise harmful to your computer. It is important to be certain that it is from a trustworthy source. Do you want to continue?"), but those outside of the company do not see it at all. The email appears to have no attachment at all. Curiously, this appears to happen randomly, and only on some computers. So if the list has 15 email lists and attachments, it seems to happen randomly to anywhere between 0 and 15 of the emails. To be clear, my objective is to send emails with regular attachments. Running Excel 2003, Outlook 2003, and Windows XP. See code below. Please help! Sub Email() Dim P As String Dim N As String Dim M As String Dim Subject As String Dim Addresses As String Dim olApp As Outlook.Application Dim olNewMail As Outlook.MailItem Application.DisplayAlerts = False M = ActiveWorkbook.Name For c = 2 To 64000 If Range("B" & c) = "" Then Exit For If UCase(Range("E" & c)) = "Y" Then Workbooks(M).Sheets("Main").Activate Subject = Range("A" & c) Addresses = Range("B" & c) P = Range("C" & c) N = Range("D" & c) If Right(P, 1) <> "\" Then P = P & "\" If Right(N, 4) <> ".xls" Then N = N & ".xls" Set olApp = New Outlook.Application Set olNewMail = olApp.CreateItem(olMailItem) With olNewMail .Display .Recipients.Add Addresses Application.Wait (Now + TimeValue("0:00:01")) SendKeys ("{TAB}") .Subject = Subject .Attachments.Add P + N .Send End With Set olNewMail = Nothing Set olApp = Nothing End If Next c Range("E2:E65536").ClearContents Application.DisplayAlerts = True End Sub

    Read the article

  • Is it possible to alter a marked field´s field function with Word 2007 VBA?

    - by Richard
    Hi, i want do the following: In Word 2007 place the Cursor on a field (or mark that field) and call a macro wich edit the field function of that field. (add some string). I´m even grateful for some tipps what term to google. I used the macro recorder and got following: WordBasic.FormatField Field:="CITATION Gro05 \p 9 \l 1031" Thats obvious creats a new field but where to go from here? To get the selected field i thought about something like this: If Selection.Type = WdFieldType Then ... I hope someone give me some hints :) Bye Richard

    Read the article

  • VBA: How go I get the total width from all controls in an MS-Access form?

    - by Stefan Åstrand
    Hi, This is probably very basic stuff, but please bear in mind I am completely new to these things. I am working on a procedure for my Access datasheet forms that will: Adjust the width of each column to fit content Sum the total width of all columns and subtract it from the size of the window's width Adjust the width of one of the columns to fit the remaining space This is the code that adjusts the width of each column to fit content (which works fine): Dim Ctrl As Control Dim Path As String Dim ClmWidth As Integer 'Adjust column width to fit content For Each Ctrl In Me.Controls If TypeOf Ctrl Is TextBox Then Path = Ctrl.Name Me(Path).ColumnWidth = -2 End If Next Ctrl How should I write the code so I get the total width of all columns? Thanks a lot! Stefan Solution This is the code that makes an Access datasheet go from this: To this: Sub AdjustColumnWidth(frm As Form, clm As String) On Error GoTo HandleError Dim intWindowWidth As Integer ' Window width property Dim ctrl As Control ' Control Dim intCtrlWidth As Integer ' Control width property Dim intCtrlSum As Integer ' Control width property sum Dim intCtrlAdj As Integer ' Control width property remaining after substracted intCtrSum 'Adjust column width to standard width For Each ctrl In frm.Controls If TypeOf ctrl Is TextBox Or TypeOf ctrl Is CheckBox Or TypeOf ctrl Is ComboBox Then Path = ctrl.Name frm(Path).ColumnWidth = 1500 End If Next ctrl 'Get total column width For Each ctrl In frm.Controls If TypeOf ctrl Is TextBox Or TypeOf ctrl Is CheckBox Or TypeOf ctrl Is ComboBox Then Path = ctrl.Name intCtrlWidth = frm(Path).ColumnWidth If Path <> clm Then intCtrlSum = intCtrlSum + intCtrlWidth End If End If Next ctrl 'Adjust column to fit window intWindowWidth = frm.WindowWidth - 270 intCtrlAdj = intWindowWidth - intCtrlSum frm.Width = intWindowWidth frm(clm).ColumnWidth = intCtrlAdj Debug.Print "Totalt (Ctrl): " & intCtrlSum Debug.Print "Totalt (Window): " & intWindowWidth Debug.Print "Totalt (Remaining): " & intCtrlAdj Debug.Print "clm : " & clm HandleError: GeneralErrorHandler Err.Number, Err.Description Exit Sub End Sub Code to call procedure: Private Sub Form_Load() Call AdjustColumnWidth(Me, "txtDescription") End Sub

    Read the article

  • How to populate data from .txt file into Excel in VBA?

    - by swei
    I'm trying to create something to read data from a .txt file, then populate data into .xls, but after open the .txt file, how do I get the data out? Basically I'm trying to get the the third column of the lines dated '04/06/2010'. After I open the .txt file, when I use ActiveSheet.Cells(row, col), the ActiveSheet is not pointing to .txt file. My .txt file is like this (space delimited): 04/05/10 23 29226 04/05/10 24 26942 04/06/10 1 23166 04/06/10 2 22072 04/06/10 3 21583 04/06/10 4 21390 Here is the code I have: Dim BidDate As Date BidDate = '4/6/2010' Workbooks.OpenText Filename:=ForecastFile, StartRow:=1, DataType:=xlDelimited, Space:=True If Err.Number = 1004 Then MsgBox ("The forecast file " & ForecastFile & " was not found.") Exit Sub End If On Error GoTo 0 Dim row As Integer, col As Integer row = 1 col = 1 cell_value = activeSheet.Cells(row, col) MsgBox ("the cell_value=" & cell_value) Do While (cell_value <> BidDate) And (cell_value <> "") row = row + 1 cell_value = activeSheet.Cells(row, col) ' MsgBox ("the value is " & cell_value) Loop If cell_value = "" Then MsgBox ("A load forecast for " & BidDate & " was not found in your current load forecast file titled '" + ForecastFile + ". " + "Make sure you have a load forecast for the current bid date and then open this spreadsheet again.") ActiveWindow.Close Exit Sub End If Can anyone point out where it goes wrong here?

    Read the article

  • Optional Fields in Infopath; Getting the xml node with VBA

    - by Sunscreen
    Hi all, I use vb to get data through my form. I have some optional fileds in my form and I have this problem with the following code: MsgBox(myXPathNavigator.SelectSingleNode("/my:Status/my:Questions/my:Questions1", _ Me.NamespaceManager).IsNode.ToString) When the optional filed 'Questions1' is inserted to the form I get the value 'true' by the IsNode function. If the field it is not inserted I have an exception, stating that the reference is not correct (and it is indeed true). Is there a way to verify about a node, whether it is present or not in my form? Thanks in advance, Sun

    Read the article

  • How can I Export a Table in Access using VBA into a specific sheet in an Excel spreadsheet?

    - by Bryan
    I have a some tables, we will call them Table1,Table2.... and I need them to be Exported into specific spreadsheets in a macro enabled Excel File (.xlsm) that already exists. So I would need to put Table1 into Sheet2, Table2 into Sheet3... and so on. I had been doing this manually by going to the export menu in Access but it is getting monotonous so I would like to automate the process. The Excel file will already have code in each spreadsheet which would need to still be intact.

    Read the article

  • Access 2007 DAO VBA Error 3381 causes objects in calling methods to "break".

    - by MT
    ---AFTER FURTHER INVESTIGATION--- "tblABC" in the below example must be a linked table (to another Access database). If "tblABC" is in the same database as the code then the problem does not occur. Hi, We have recently upgraded to Office 2007. We have a method in which we have an open recordset (DAO). We then call another sub (UpdatingSub below) that executes SQL. This method has its own error handler. If error 3381 is encountered then the recordset in the calling method becomes "unset" and we get error 3420 'Object invalid or no longer set'. Other errors in UpdatingSub do not cause the same problem. This code works fine in Access 2003. Private Sub Whatonearth() Dim rs As dao.Recordset set rs = CurrentDb.OpenRecordset("tblLinkedABC") Debug.Print rs.RecordCount UpdatingSub "ALTER TABLE tblTest DROP Column ColumnNotThere" 'Error 3240 occurs on the below line even though err 3381 is trapped in the calling procedure 'This appears to be because error 3381 is encountered when calling UpdatingSub above Debug.Print rs.RecordCount End Sub Private Sub WhatonearthThatWorks() Dim rs As dao.Recordset set rs = CurrentDb.OpenRecordset("tblLinkedABC") Debug.Print rs.RecordCount 'Change the update to generate a different error UpdatingSub "NONSENSE SQL STATEMENT" 'Error is trapped in UpdatingSub. Next line works fine. Debug.Print rs.RecordCount End Sub Private Sub UpdatingSub(strSQL As String) On Error GoTo ErrHandler: CurrentDb.Execute strSQL ErrHandler: 'LogError' End Sub Any thoughts? We are running Office Access 2007 (12.0.6211.1000) SP1 MSO (12.0.6425.1000). Perhaps see if SP2 can be distributed? Sorry about formatting - not sure how to fix that.

    Read the article

  • Making an Excel file into a link in VBA.

    - by Edmond
    Mvalue = MonthName(5, True) fileL = \bobby\outside\" myFile = fileL & Mvalue & Right(Year(Date), 2) & "\Goodbye - " & myfdate & ".xls" Set omail = CreateItem(olMailItem) With omail .Subject = "Hello" .BodyFormat = olFormatHTML .HTMLBody = myFile How do I make the.HTMLBody = myFile, into a link within the email that will be sent out

    Read the article

  • How can I have a VBA macro perform a Search/Replace in formulas across an entire workbook?

    - by richardtallent
    I distribute an Excel workbook to a number of users, and they are supposed to have a particular macro file pre-installed in their XLSTART folder. If they don't have the macro installed correctly, and they send the workbook back to me, any formulas depending on it include the full path of the macro, e.g.: 'C:\Documents and Settings\richard.tallent\Application Data\ Microsoft\Excel\XLSTART\pcs.xls'!MyMacroFunction() I want to create a quick macro I can use to remove the improper path from every formula in the workbook. I've successfully retrieved the special folder using GetSpecialFolder (an external function that is working just fine), but the Replace call itself shown below throws an "Application-defined or object-defined error". Public Sub FixBrokenMacroFormulas() Dim badpath As String badpath = "'" & GetSpecialFolder(AppDataFolder) & "\Microsoft\Excel\XLSTART\mymacro.xls'!" Dim Sheet As Worksheet For Each Sheet In ActiveWorkbook.Sheets Call Sheet.Activate Call Sheet.Select(True) Call Selection.Replace(What:=badpath, Replacement:="", LookIn:=xlFormulas) ''//LookAt:=xlPart, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False Next End Sub Automating search and replace isn't exactly my forte, what am I doing wrong? I've already commented out some of the parameters that don't seem essential.

    Read the article

  • Access VBA remove CR & LF only from the beginning of a text string by searching for them

    - by uZI
    Hi there I need to remove line breaks from the beginning of a memo type records. I dont want to use the replace function as it would remove all line breaks from the record which is not desired. Its only the line breaks at the beginning of the field that I am interested in removing. Furthermore, the my records do not always begin with a line break so I cant really use text positioning, the solution would be to look for line break at the beginning instead of always expecting it at the beginning. click here for a sample of what my data looks like any help will be greatly appreciated

    Read the article

  • How do I correctly use two Not Exists statements in a where clause using Access SQL VBA?

    - by Bryan
    I have 3 Tables: NotHeard,analyzed,analyzed2. In each of these tables I have two columns named UnitID and Address. What I'm trying to do right now is to select all of the records for the columns UnitID and Address from NotHeard that don't appear in either analyzed or analyzed2. The SQL statement I created was as follows: SELECT UnitID, Address INTO [NotHeardByEither] FROM [NotHeard] Where NOT EXISTS( Select analyzed.UnitID FROM analyzed WHERE [NotHeard].UnitID = analyzed.UnitID) or NOT EXISTS( Select analyzed2.UnitID FROM analyzed2 WHERE [NotHeard].UnitID = analyzed2.UnitID) Group BY UnitID, Address I thought this would work since I've used the single NOT EXISTS subquery line and it has worked just fine for me in the past. The above query however returns the same data that is in the NotHeard table whereas if I take out the or NOT EXISTS part it works correctly. Any ideas as to what I'm doing wrong or how to do what I'm wanting to do?

    Read the article

  • How do I set selection to Nothing when programming Excel using VBA?

    - by Curt
    When I create a graph after using range.copy and range.paste it leaves the paste range selected, and then when I create a graph a few lines later, it uses the selection as the first series in the plot. I can delete the series, but is there a more elegant way to do this? I tried Set selection = nothing but it won't let me set selection. I also tried selection.clear, but that just cleared the last cells that were selected, and still added an extra series to the plot. Curt

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >