Inserting a templated letterhead into existing word document via a macro along with an image at a specific line
I have a very specific question. I have to insert letterheads and a signature in many word documents as a daily task. I'm looking to automate this procedure through a macro or other solution so I can focus on other tasks. What are the best ways to go about this?
See also questions close to this topic
-
How can I make a shape from a slide appear in another slide using VBA for powerpoint?
I'd like to make a shape from a slide 2 appear on a slide 1 on powerpoint using VBA, Do you know how can I do it?
PS: I actually tried to develop some codes but they didn't work at all...
Code I tried to develop but didn't work at all...
slide1(slide2.shapes("A").visible = msotrue)
-
Restructure Excel table with VBA
I have an Excel table source (extract is below):
Models are changing (adding new names, removing), so does change Week number in Columns (from Now till end of the year)
I need to restructure it so that it could look like this:
So that it could be normally used for further querying. In each row there must be model name, for each model there should be Week number and corresponding matching Quantity taken from the table itself (on the intersection of Model X Week from original table). I was smashing my head against the wall on how it can be realized in VBA. Couldn't restructure it with simple code.
-
Worksheet calculate stops for no reason
I'm running worksheet calculate to grab data from DDE as it comes in. It works fine 99% of the time, but occasionally when I check it its just sat there doing nothing. if I toggle the on/off button it carries on as if nothing happened, no error shown. I've checked if it could have got stuck while on screenupdating=false or calculation=manual but there's no way. Is it possible Excel 2016 just pauses if left unattended, or am I missing something?
-
Automatically Transfer from Excel to a Tab Delimited List in Word
I have a table in excel which has the data I would like to transfer to a word document. Based on which column the values are in I am trying to put the data into a different tabbed order (Ex: List Level 1 is initial list, List Level 2 is pressing tab once in list).
I am trying to do this by recognizing a cell on a previous sheet and the code I have so far works to get the word document open but in order to actually bring in the data I can't seem to figure it out.
My current code is show below (I have the word document "Template.docx" in the same folder:
Private Sub CreateList() Dim WRD As Object, DOC As Object On Error Resume Next Set WRD = CreateObject("Word.Application") If Err.Number <> 0 Then Set WRD = CreateObject("Word.Application") End If On Error GoTo 0 Set DOC = WRD.Documents.Open(ThisWorkbook.Path & "\Template.docx", ReadOnly:=True) WRD.Visible = True If Sheet1.Range("A1").Value = "Package 1" Then With DOC ' INSERT DATA FROM EXCEL INTO A TAB DELIMITED LIST End With End If Set WRD = Nothing Set DOC = Nothing End Sub
-
C# Word.Interop System.NullReferenceException: "Object reference not set to an instance of an object."
Below is my code, which should open a .docx template from the given path. This seems to work just fine, but a s soon as the first paragraph should get pushed into the template i get an NullReferenceException (marked with /**/) As you can see at the top, there is the initiaized object "oEndOfDoc". What am i missing here? Why is my object "null"? I got the same Error, if i tried to use ref oMissing for the Add()-function below this Error.
What might be interesting is, that this Error didn't occur when i created a fresh document instead of opening a template.
//Missing + EndOfDoc object oMissing = System.Reflection.Missing.Value; object oEndOfDoc = "\\endofdoc"; //Start Word and create a new document. Word._Application oWord; oWord = new Word.Application(); object template = "\\net5.0-windows\\Templates\\Root\\TemplateMain.docx"; object pathtemp = String.Concat(@"" + $"{Directory.GetCurrentDirectory()}", template); Word._Document oDoc = oWord.Documents.Add(ref pathtemp); oWord.Visible = true; //Headline Word.Paragraph Überschrift; **object oRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;/*This is where i get "System.NullReferenceException: "Object reference not set to an instance of an object."*/** Überschrift = oDoc.Content.Paragraphs.Add(ref oRng) Überschrift.Range.InsertParagraphBefore(); Überschrift.Range.Font.Name = "Arial"; Überschrift.Range.Text = "I N S P E C T I O N P L A N"; Überschrift.Range.Font.Bold = 1; Überschrift.Range.Font.Underline = Word.WdUnderline.wdUnderlineDouble; Überschrift.Range.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; Überschrift.Range.Font.Size = 14; Überschrift.Format.SpaceAfter = 10; Überschrift.Range.InsertParagraphAfter();
-
How to record toolbar use in PPT/XL/WORD?
I am a giant efficiency dork and I would like to record the toolbar buttons that I use in powerpoint, excel and word over the span of a few months (or shanghai others to do it as well). This way after a few months I can go through and make some toolbar arrangements that I know have the buttons I use.
Is there any way to do this for one or all of the applications? I have not worked with vba before so gentle guidance would be much appreciated.
Thanks!
-
Can I subscribe to an event for when an event starts within Office 365?
So I am trying to create an Azure Function that is triggered every time an event starts in an Office 365 calendar. It's pretty straightforward to me how to register for event changes, but is there a way to subscribe to an event start?
-
Remove Disabled users in a CVS file from all Office 365 Groups that appear on the admin portal
I am Trying to Remove all users who are in a csv file from all the groups they are showing up under in the Office 365 admin portal, The code bellow doesn't seem to delete all the groups and still has some left under their name. Is there something I am missing?
Write-Host "Fetching the CSV..." $file = "X:\1Onboarding.TerminationCSV\DisabledUsers.csv" Write-Host "Importing from $file..." $csv = Import-Csv $file if ($csv -eq $null) { Write-Host "No CSV file found. exiting script in 3 seconds" #Start-Sleep -Seconds 3 Exit } #Credentials $password = ConvertTo-SecureString “*Hidden*” -AsPlainText -Force $Cred = New-Object System.Management.Automation.PSCredential (“*hidden*”, $password) #Connect to AzureAD Connect-AzureAD -Credential $Cred #Get all Azure AD Unified Groups $AADGroups = Get-AzureADMSGroup -All:$true foreach ($member in $csv) #loop through csv for users-------------------- { $username= $member.username Write-Output "username is $username" #Get the Azure AD User $AADUser = Get-ADUser -filter {sAMAccountName -eq $username} $groupCount = 0 ForEach ($Group in $AADGroups) { $GroupMembers = (Get-AzureADGroupMember -ObjectId $Group.id).UserPrincipalName If ($GroupMembers -contains $UserUPN) { Write-Output "$username is in $($Group.DisplayName)" #Remove user from Group try { Remove-AzureADGroupMember -ObjectId $Group.Id -MemberId $AADUser.ObjectId } catch { "$($Group.DisplayName) is not an azure group" } try {Remove-DistributionGroupMember -Identity $Group.Id -Member $AADUser.ObjectId -BypassSecurityGroupManagerCheck -Confirm:$false } catch { "$($Group.DisplayName) is not a distribution group" } $groupCount +=1 } } Write-Output "$AADUser is in $groupCount groups" }
-
Get SharePoint online user access token without registering as app
I am looking at way to get user token with userid and password for sharepoint online via c#. I can register as app with clientid and client secret but I am not looking for it.
PnP has powershell commend Get-PnPAccessToken and just need same via C#.
Is there a way to get it for SharePoint online via c#?
Many thanks,
-
Usage of INDIRECT excel function
I've got sheet with name
April 21
and other sheet with nameSummary
.I'd like to prepare cell formula in
Summary
sheet that will refer toApril 21
sheet's cellM10
. This works for me just fine, it displays valid value inSummary
sheet cell:='April 21'!$M$10
I try to generify this formula using
INDIRECT
formula, but it doesn't work at all=INDIRECT("'" & $D$6 & " " & RIGHT($B$3;3;2) & "'!$M$10")
where
D6
contains month name andB3
contains a concrete year, like 2021.What is wrong with my formula?
-
How can flag recipients for follow up flag
Simply: when i press on the button (macro) it flags follow up for me only. Can any one amend the code to flag me and the recipients
The below code adding follow up flag to me only when I press on the macro button. I just need to add the flag follow up for whom I sending the email on the same date.
Sub Button1_Click() Dim EmailApp As Outlook.Application Set EmailApp = New Outlook.Application Dim EmailItem As Outlook.MailItem Set EmailItem = EmailApp.CreateItem(olMailItem) With EmailItem .To= Range("L4") .CC= "someone@somewhere.com" &";"&"someone2@somewhere.com" . Subject="" .Body ="" .FlagStatus = olFlagMarked .FlagRequest = "Follow up" .ReminderTime = Range("I1").value & " 10:30 AM" .ReminderSet = True .ReminderOverrideDefault = True .send End With End Sub
-
how do you make a macro that creates invoices from my data?
I have to create an invoice using macros for my assignment but I do not know how to code. How do you create an invoice that inputs data from my other sheets (same document) when I click a button and how do I get it to behave like a vlookup?